This article is more than 1 year old

Stuck on a coding problem – should you Bing it?

Bing Developer Assistant brings web search to Visual Studio editor

Microsoft has released the production version of Bing Developer Assistant for Visual Studio, which has been in preview since August 2014.

Bing Developer Assistant

The developer workflow today often looks like this: write some code, hit problem, Google for answer, continue. Software platform creators are still in love with creating, expanding and replacing APIs, which means the chances of holding everything you need in your head are slim – unless you happen to work in a small and familiar niche. Some variant of code, search and continue is inevitable.

Bing Developer Assistant (BDA), which is based on earlier projects called Code Search and Sample Browser, integrates this kind of help into the Visual Studio IDE. It is installed as an extension, and when enabled it adds several features for C# developers.

The most prominent of these extends the code completion feature in the editor, so that as you type you are prompted not only with a list of likely keywords with a brief description, but also a code sample drawn either from MSDN (Microsoft’s online developer resource) or Stackoverflow, a popular developer Q&A site which has a measure of official support. The search also extends to the local hard drive, so you can see samples of your own code, or that of a colleague.

Bing Developer Assistant code completion

Bing Developer Assistant code completion

The extension also adds a search box to the Visual Studio toolbar, for code samples and sample projects, drawing on the same sources. Results appear in the IDE, but only the code is shown, not the entire page from which it is drawn, unless you click the link to see more.

This lack of context can be a problem. For example, if you search for “AD Graph API”, which is for accessing Azure Active Directory programmatically, you get a code snippet for retrieving a user list. Click the link though, and a note states: “This sample is outdated. Its technology, methods and/or user interface instructions have been replaced by newer features”.

Bing Code Search

Looks good - but click the link and discover the code is obsolete

The same is true of the in-editor code samples. A sample from Stackoverflow, for example, might be in the user’s question asking why the code does not work. No doubt clicking the link and reading about the issue might help the developer not to make the same mistake, but presenting it in the editor without any warning could trip up someone in a hurry.

Help with compile fails

BDA has some more tricks. If your compile fails, you can right-click an error and choose Bing contextual search. This generates a local search results page which opens in a web browser. Since it is a generated file, there are no search engine advertisements or other distractions. It is also meant to be a better search than simple typing the error into a browser, because it automatically takes account of details like the version of Visual Studio and the type of the project.

Bing Contextual search works in the editor too. Select some text, right-click and go. This piece works well, though it is odd that there is no option to have the results in the IDE rather than an external browser window. Microsoft says that 98 per cent of its own APIs have code samples, and that nearly 19 million code samples are covered. Future plans include extending the scope of the search to GitHub, CodePlex and other sites.

Although integrating the IDE with web search seems to make sense, there are several problems with BDA. One is that it only supports C#. Another is that you cannot configure the search engine; a common request is for an option to have the big G power the results. You cannot even tweak the list of search destinations.

The wider question is whether this kind of feature will improve code quality. Code samples are valuable for learning how a language feature or API works, but in the majority of cases they are not intended for production use. Exception handling may be omitted to simplify the code, and the arguments passed to functions may use more or fewer defaults than would be typical in production.

That does not mean code samples are bad, but does Microsoft’s BDA encourage the poor practice of indiscriminate copy/paste of random code in the hope that it will work? Developers who do that will never be any good (with or without BDA), but if the IDE should encourage best practice, perhaps the current approach is misconceived.®

More about


Send us news

Other stories you might like