Search and navigation in Visual Studio

60
Code How Updating Your Code Search Tool and Tweaking Your Workflow Can Dramatically Effect Your Productivity @DavidCShepherd Senior Principal Scientist Search Sucks

Transcript of Search and navigation in Visual Studio

  1. 1. Code How Updating Your Code Search Tool and Tweaking Your Workflow Can Dramatically Effect Your Productivity @DavidCShepherd Senior Principal Scientist Search Sucks
  2. 2. How do you find relevant code?
  3. 3. Are you an aimless Poker? Warning: You will usually guess wrong.
  4. 4. Are you a random Scroller? Warning: You will read tons of irrelevant code.
  5. 5. Are you a hopeless grepper? Fact: Your searches will fail most of the time.
  6. 6. An unranked searcher? Warning: Relevant results may appear at the bottom of the list!
  7. 7. There is a better way
  8. 8. A better way to start searches. Based on Research Refined by Users Improved by UX Design
  9. 9. A better way to continue searches. Avoid aimless scrolling Navigate the program graph* * strategy based on research showing its extreme effectiveness
  10. 10. Improving Search + Navigation is High Impact [Source: Ko, A. et al. IEEE TSE. 2006] 41%time reading, searching, and navigating code, Developers spend over Handling Interruptions Testing Reading Docs Editing Code Reading Tasks Navigating Code Searching Code Reading Code Switching Apps Todays goal: regain your development productivity
  11. 11. Activity Time! + Search a Neighbors Project Using FindInFiles Download Sando + Demonstration Solution http://bit.ly/devLinkSando
  12. 12. A tiny bit of academic theory
  13. 13. How Do Developers Start Tasks?
  14. 14. Q1: Find a Starting Point [Questions Programmers Ask During Software Evolution Tasks, FSE 2006]
  15. 15. Q1: Find a Starting Point [Questions Programmers Ask During Software Evolution Tasks, FSE 2006] Concrete questions like 1. Which type represents this domain concept or this UI element or action? 2. Where in the code is the text in this error message or UI element? 3. Where is there any code involved in the implementation of this behavior? 4. Is there a precedent or exemplar for this? 5. Is there an entity named something like this in that unit (for example in a project, package or class)?
  16. 16. Q2: Building on Those Points [Questions Programmers Ask During Software Evolution Tasks, FSE 2006] Concrete questions like 1. Where is this method called or type referenced? 2. When during the execution is this method called? 3. Where are instances of this class created? 4. Where is this variable or data structure being accessed? 5. What data can we access from this object?
  17. 17. Is There a Problem? [Questions Programmers Ask During Software Evolution Tasks, FSE 2006] Starting Point Building
  18. 18. Is There is a Problem 88 percent (11) of developers searches led to nothing of later use in the task -Ko, TSE 2006 Poor navigation patterns led to failed tasks, longer task times, and incorrect fixes. -Robillard, TSE 2004 Starting Point Building
  19. 19. Todays Focus Demonstrating the problems Find initial focus points w/o wasting time Build on those points more effectively Estimated impact: 10-40% speedup on maintenance tasks Because right now, you dont believe me.
  20. 20. The Data
  21. 21. Q1: Find a Starting Point [Questions Programmers Ask During Software Evolution Tasks, FSE 2006]
  22. 22. Q1: Developers say. To find the code, I use one of the following to get started : my knowledge of the code base, find entry point and trace using the debugger to get to the correct location, use the provided stack trace, use common naming conventions to find relevant class. If I'm not familiar with the code base, I'll start browsing the code base looking for packages and classes whose name correspond to the problem domain. This browsing, combined with searching for probable class names (i.e. Ctrl+Shift+T in Eclipse) will usually do the trick. If there isn't an obvious UI-hook, then I'll start by searching class names (using ReSharper) for probable keywords (e.g. export).
  23. 23. Starting a task is hard I use one of the following to get started This browsing, combined with searching.. If there isn't an obvious UI-hook, I Q1: Developers say.
  24. 24. You will need to search use common naming conventions to find relevant class searching for probable class names searching class names (using ReSharper) for probable keywords Q1: Developers say.
  25. 25. Q1: Developers act
  26. 26. Q1: Find a Starting Point
  27. 27. Q1: Developers act When searches fail102 minutes wasted, task failed When searches succeed 26 minutes to success, task passed Failed searches have a compounding interest effect on task performance
  28. 28. Q2: Building on Those Points [Questions Programmers Ask During Software Evolution Tasks, FSE 2006]
  29. 29. Q2: Developers say. I more heavily utilize structured navigation, such as following references, then scrolling through an open file. Scrolling around a file / solution list is useful for about ten seconds to get the lay of the land if you know you're in the right place, but after that stumbling on to what you're looking for seems to be pretty rare. Same as last answer I find debugging code to be a fantastic tool for structured navigation. I'm trying to reduce scrolling to 0%. In almost all the cases I can navigate to the code I want to see by shortcuts, especially using ReSharper. I'm scrolling only when it takes less time than a shortcut- based way, like when the method I want to look at is several lines below, so scrolling takes less time than "Go to member" shortcut along with typing the method name Structured navigation : 90% Scrolling : 10%
  30. 30. Strongly prefer structured navigation I more heavily utilize structured navigation.. I'm trying to reduce scrolling to 0%.. Structured navigation : 90% Q2: Developers say.
  31. 31. Q2: Developers act
  32. 32. MainWindow Container addPropertyChang eListener FilteredTasks TabelModel setTasks HistoryView btBackwardActionPerformed btForwardActionPerformed cmbPeriodItemStateChanged propertyChange filterTasks initComponents jtProjectsMouseMoved pnTasksMouseMoved updateTotalTime formWindowClosing formWindowIconified getFont main initComponents TaskDialog DayView AbstractTableModel getGroupSameTask s setGroupSameTasks sortTable HistoryChart btAddFilterActionPerformed btEditFilterActionPerformed btRemoveFilterActionPerforme d btReportActionPerformed chbGroupTasksActionPerforme d chbHighlightTasksActionPerforme d checkButtons cmbContentRuleItemStateChange d cmbFilterNameItemStateChanged formMouseMoved getDate getDays getFilter getFont itemStateChanged loadSetup MouseActionAdapter mouseClicked mouseEntered mouseExited pnProjectsMouseMoved pnTimesMouseMoved rbFromToActionPerformed rbTimeUsageActionPerformed saveSetup setComponents shiftPeriod spFiltersMouseMoved spMinusStateChanged spPlusStateChanged spTasksMouseMoved tbFiltersKeyReleased tbFiltersMouseClicked txtDateMouseClicked valueChanged mousePressed actionPerformed Q2 Result: Large Model
  33. 33. Password Dialog Unlock DbAction Password SafeJFace Lock DbAction open widget Selected create Contents shell perform Unlock setLocked showListView addTableView tableViewer updateViewers getPwsDataStore setPwsFile perform Lock Q2 Result: Focused Model
  34. 34. Q2: Developers act.. Ineffective navigation task takes 110 min, results in huge model Effective navigation task takes 8 min, results in focused model Errant navigations also have a compounding interest effect on task performance
  35. 35. Both Surveys and Data Strongly Suggest Search + Navigation Skills Effect Task Performance Surveys Data
  36. 36. How to become an effective searcher and navigator @Moyan_brenn
  37. 37. The State of the Search 88 percent (11) of developers searches led to nothing of later use in the task -Andrew Ko, Transactions on Software Engineering, 2006
  38. 38. Your Search Tool Has. No auto-correct/suggest SoltuionFile Find all SoltuionFile
  39. 39. Presents results as text Solution Find all SoltuionFile Your Search Tool.
  40. 40. Offers no preview, terse summary Your Search Tool.
  41. 41. Your Search Tool Doesnt rank results Find all SoltuionFile
  42. 42. Tips for Searching Tip #1: Upgrade search tool Tip #2: Remember to use new search tool Free, OSS
  43. 43. Sando Code Search Tool Advantages Ranked results Auto-correct Spelling Existence Synonyms Extensive preview Term highlighting Auto-complete Word cloud complete Near-instant results
  44. 44. Activity Time! Install Sando by clicking on UI.vsix + Unzip + open demonstration solution
  45. 45. Follow-Along Sando Demo
  46. 46. Tips for Searching Tip #1: Upgrade search tool Tip #2: Remember to use new search tool
  47. 47. The State of Navigation Poor navigation patterns led to failed tasks, longer task times, and incorrect fixes. -Martin Robillard, Transactions on Software Engineering, 2004
  48. 48. Tips for Navigating: Existing Tooling Tip#1: Know your views VS offers references, call hierarchy, goto- definition, navigate-to, code maps for 2012, etc. Tip #2: Practice disciplined development Coderetreat constraint exercise: Name: Structure constraint Description: Only structured navigation and searches are allowed (no scrolling or use of Solution Explorer). Learning goal: Become a more effective, focused navigator.
  49. 49. Navigation Demo
  50. 50. Tips for Navigating: Existing Tooling Tip#1: Know your views Tip #2: Practice disciplined development The Solution Explorer is not your friend.
  51. 51. In Review [Questions Programmers Ask During Software Evolution Tasks, FSE 2006]
  52. 52. Find a Starting Point [Questions Programmers Ask During Software Evolution Tasks, FSE 2006]
  53. 53. Building on Those Points [Questions Programmers Ask During Software Evolution Tasks, FSE 2006]
  54. 54. Is There is a Problem 88 percent (11) of developers searches led to nothing of later use in the task -Ko, TSE 2006 Poor navigation patterns led to failed tasks, longer task times, and bad fixes. -Robillard, TSE 2004 Starting Point Building
  55. 55. There are Solutions Sando Search Tool Practicing Structured Navigation Starting Point Building
  56. 56. Todays Steps Towards Effectiveness Install better (free, OSS) tooling Sando for Visual Studio: http://bit.ly/Sandov0_4 Practice good habits On your own Limit yourself to modern search tools + structured navigation for one task/day coderetreat.org Dedicate a day to becoming a better team of programmers
  57. 57. Activity Time! Rule: DO NOT use Solution Explorer! Sando + Navigation 1) Add support for 1-1-2002 format as well 2) Ensure you support this format in all places