After my drywall guy told me that everybody cannot do what he does, he started talking about web development and how he doesn’t code but
finds code on the web and makes it his own. I know some developers would be offended by his admission, but copy and paste coding is the norm these days. Here’s a look at a tool for Visual Studio called Flow that makes it easier to find code that fits your
needs.

Searching in Visual Studio

Finding code via Google or another search engine requires
you to switch to a browser and start typing. The Flow extension for Visual Studio
(currently, versions 2010, 2012, and 2013 are supported) brings the search to
the IDE, so there’s no need to divert your attention away from the task at
hand. Flow supports all programming languages.

The extension is easily installed via
the download link on the Flow website. Figure A shows Flow in the list of installed extensions for
my copy of Visual Studio 2012 (Tools | Extensions And Updates menu).

Figure A

After Flow is installed, it will appear in the extensions list. (See an enlarged view of the image.)

The feature is available within your code by
simply using the //? syntax as the search prefix to find what
you need. After you enter a search string, and with the cursor on the search line, hit the Flow key combination
(Ctrl+Shift+M). Search results are
returned in a window, with the most relevant at the top. You can scroll through
the list, and whatever snippet you choose (if you choose any) is inserted directly into your source
code. A tool window appears just below the code window; details on the highlighted answer are included in the window.

Figure B shows Visual Studio 2012 opened with a Flow search
conducted to find help on adding items to a C# List. You can easily navigate the answer list with the arrow keys or with a mouse. Notice the Flow Answer
window (in the middle) that provides details on the highlighted answer. Some
items are grouped together in the answers list (they have blue left/right arrows
as the highlighted answer in Figure B). Code is inserted when you select an answer by hitting Enter or clicking the check mark (Figure C).

Figure B

Searching for C# syntax using Flow in Visual
Studio 2012. (See an enlarged view of the image.)

Figure C

An answer is chosen with the text inserted into
the source code. (See an enlarged view of the image.)

In only a couple of simple steps, code is where you need it — but is it
the right code? It seems to pull the first snippet from the answer details that
is clicked, so it can be a bit tricky. While no code often provides a complete
solution, the search results seem to be in the ballpark of what is needed.

Flow also provides type-ahead when working with CSS (Figure D).

Figure D

Flow type-ahead search shown in CSS source file. (See an enlarged view of the image.)

It’s usually a slow process, as
multiple searches are often required to find what you need or something very
close to it. This is not unlike a standard web search, where you do it repeatedly to
trim results down to what you need.

There will be scenarios in which you
don’t find anything useful or anything at all (Figure E), and that just
means you have to create code from scratch or
enter better search terms. If you create new code for a problem, post it on Stack Overflow or elsewhere on the web for others to use.

Figure E

Sometimes Flow doesn’t find answers to questions. (See an enlarged view of the image.)

Flow is not entirely random or
just a straight Google search; its documentation states that it uses Stack Overflow as its main source for
answers. In addition, Flow embraces the social aspects of the web by using a
code-ranking algorithm based upon Flow users’ choices. This means you
need to trust other Flow users or at the very least trust Stack Overflow as a
valuable source of technical details.

As a test, I conducted searches via Google and then
used Flow within Visual Studio 2013. The results were very different each time, but every result provided useful answers. The main difference was that
Flow relied heavily on Stack Overflow.

It helps to be clear about what you want

Initially, it was difficult to get comfortable using Flow with its special syntax and keystrokes, and I had to stop myself from switching to a browser to conduct my search. The
usefulness of Flow search results varied, though most often it was due to my poor choice of search
terms, which is no different than what I would experience with a Google search.

The Flow extension is currently in beta. It will be interesting to see what changes will be implemented before Flow is officially released. The Flow blog seems like a good place to keep up with product news.