Advanced Code Search in Visual Studio using Sando

This article was Guest blogged by David Shepherd and is intended to give information about a free code search tool extension in Visual Studio.

For large projects, new developers can take weeks or even months to become productive contributors. To acclimate them to their new project, team leads often start developers off with bug fixing or smaller tasks. In this scenario, new developers find themselves staring at thousands of lines of code, completely lost as to how to begin. Fortunately, a new set of tools is quietly becoming available that accelerates the learning process. This post will detail how to use the features of next-generation FindInFiles tools, such as query recommendations, instant search, and quick review workflow, to avoid the common problems that new developers face.

To follow along download the Sando Code Search Tool, a free, open source Visual Studio extension.
Developer Dan Joins Family Lines.

Today let’s consider an imaginary scenario where Developer Dan from company XYZ joins the proprietary Family Lines project. The Family Lines project allows users to create, maintain, and edit family trees. A screenshot is included below:

family-tree

As you can see in the screenshot above, both a father (blue) and a mother (orange outline) can be created, and children can be added (orange filled). The blue button on the right hand side of the screen allows you to add a daughter, mother, sister, brother, or father to the selected person.
Now, imagine that when a user chooses the option “add daughter” the links are not properly drawn between the father and daughter. Unlike in the screenshot above, the lines between father and daughter are missing. Let’s consider the steps that a developer would take to fix this bug.

Without Advanced Search Tools

First, let’s consider what the developer may do without advanced tool support. The developer will likely use FindInFiles to search for the word “daughter”. Performing this search on the code base will return 33 results, none of which are relevant.

findinfiles

33 hits, none of them relevant

Next, the user is likely to search for “add”. Unfortunately, this search is equally useless, as a search for add returns 1060 results, which the user would have to weed through in order to find the relevant code. There must be a better way!

With Advanced Search Tools

Fortunately, there is a better way to start a task thanks to modern search libraries, years of academic research, and a few innovative tool builders. Today we will use the Sando Code Search Tool (a free, open source Visual Studio extension), which provides a modern search experience for developers, ultimately making them more productive.

Using Sando developers can eliminate the problems experienced by the FindInFiles user. The Sando user would simply begin by typing “add” into the Sando search box.

add-child

As you can see in the screencast above (Click here to see the animated gif in action), as the developer types “add” several recommendations are suggested based on the actual word usage in the Family Lines project. While the words “add” and “daughter” don’t appear together in the project, the recommendations help the developer quickly realize that the correct search terms are “add child”, thus avoiding several failed searches before they happen.

Once the developer executes the search it is easy to review the results without opening a single file. The developer navigates down the result list using the arrow keys and each matching method, class, or field is shown in a preview popup with relevant terms highlighted.

review-results

Click here to see the animated gif

To upgrade your search experience download the Sando Code Search Tool, a free, open source Visual Studio extension or check out Entrian Source Search.

This article was Guest blogged by David C. Shepherd. David is a software engineering researcher and research area coordinator with ABB, Inc. based in Raleigh, N.C. While working with ABB's Software Engineering Group he looks into improving developer productivity and increasing software quality. While he is a researcher, and thus often found writing papers and attending research conferences, his industrial background compels him to actually implement his ideas as software tools. His current passion is creating better search tools for developers as the project lead for Sando, an open source code search tool and Visual Studio extension.

5 comments:

  1. Nice example, David - and big thanks to you and Suprotim for helping to raise the profile of new-generation search tools! This is an area where the default tooling in the major IDEs is sadly lacking, but many developers don't realise there are much better alternatives available.

    I gave this example a quick try with Entrian Source Search, and I'm pleased to say it works very well for finding the relevant code - a search for "add daughter" takes you straight to the command in the resx file, and from there to the XAML and the relevant click handler.

    ReplyDelete
  2. Nice example, David - and big thanks to you and Suprotim for helping to raise the profile of new-generation search tools! This is an area where the default tooling in the major IDEs is sadly lacking, but many developers don't realise there are much better alternatives available.

    I gave this example a quick try with Entrian Source Search, and I'm pleased to say it works very well for finding the relevant code - a search for "add daughter" takes you straight to the command in the resx file, and from there to the XAML and the relevant click handler.

    ReplyDelete
  3. I have personally tried Entrian Source Search and find it also to be an excellent advanced search tool. Built from the same underlying technology (i.e., Lucene.NET), it does a great job of finding relevant results quickly, with a very polished user experience.

    ReplyDelete
  4. Which versions of Visual Studio does this tool support?

    ReplyDelete
  5. > Which versions of Visual Studio does this tool support?

    VS2010, VS2012, and VS2013... enjoy!

    ReplyDelete