Drastically leverage your Code Reviews

 

Normal
0

false
false
false

EN-US
X-NONE
X-NONE

MicrosoftInternetExplorer4

I usually try to avoid superlative in blog posts’ titles but
I am really enthusiast about the last 2.12 version of NDepend that we just released. As
usual, before releasing this new version 2.12, we did an intensive code review
of code that have been refactored or added since the previous release (version 2.11.2). During this step the usefulness of the new features stuck me!

So what’s new? Basically 2 big things: we introduced a new
Search panel and we hierarchically present code elements matched by a CQL query. On the picture below, we can see NDepend code base v2.12.0 compared to
v2.11.2. In 2 mouse clicks, the new search panel selects methods that have been refactored
(underline font) or added (bold font).
On the result, we can now drill down in the hierarchy of assemblies/namespaces/types/methods
that have been changed/added. Notice that for each assembly/namespace/type, the
underlying number of methods matched is provided.

Searching what have been changed is just one of the many
possibilities offered by the search panel. You can search by Name, Size, Complexity,
Coupling, Popularity, Coverage, Visibility, Mutability, Purity, Change and Coverage
of Changes and I will make sure to explain all this in future posts.

The key is that this search panel is in fact a
CQL Query generator. In the picture above, notice the CQL Query Generated:

SELECT METHODS
WHERE CodeWasChanged OR WasAdded

Thus, this search panel is an excellent way to 1) learn interactively
about what CQL can do for you 2) generate very quickly basic CQL Queries. Also,
clicking the button Edit Query let’s edit the basic query generated and refine it for specific needs.
Typically, while doing a code review we want to focus on the quality of the
code reviewed and how it is covered by tests. Just add the suffix ORDER
BY
CyclomaticComplexity, PercentageCoverage et voila!

Now not only one see at a glance exactly where the work was
recently focused, but also one can evaluate readily the quality of the recent work.
Also, the result panel remembers magically
which types were expanded/collapsed across multiple CQL Query edition
and other visual artifacts you might have tweaked. And the numerous
days spend on performance paid off with an immediate refresh of all
these,
even if millions of code elements are matched.

 

Let’s now combine this possibility with the fact that VisualNDepend
knows about where code elements are declared in source files: you can, in a
click, compare 2 versions of a method changed with your preferred diff tool.
Alternatively you can open in Visual Studio the old or the new declaration of
any code element changed/added/removed:

 

You can also benefit from the metric/treemap view to get an
intuitive understanding of what have been changed/added. The query result and search
panels work hands-in-hands with the metric/treemap view. On the following
screenshot we can see that 32 methods (in magenta on the treemap) of the
namespace NDepend.UI.MainPanel.MainFormResponsabilities
(in red on the treemap) have been changed or added. From the treemap, we can
infer that the bulk of these modified methods are roughly in the same type
because magenta squares are aggregated.

 

Notice that we also added the possibility to work simultaneously
with several Search panels and Query Results panels. This is for more
elaborated use-cases scenario where one needs to harness multiple search
results.

 

In future posts I’ll ramble on more central use-cases of these
new search/result panels.

 

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.NDepend.com Patrick Smacchia

    Kevin, thanks for this english point

  • http://www.beautifulfutility.com Kevin Stevens

    My apologies for being a bit pedantic, but grammar is one of my things.

    “Dramatically” is not a negative word. It speaks only to a matter of degree and implies a sense of “wow”. To say that a change is dramatic is not a question of good or bad, the same is generally true of drastic.

    Either word is fine.

  • http://www.NDepend.com Patrick Smacchia

    Thanks Frans ;o)

  • http://weblogs.asp.net/fbouma Frans Bouma

    I think you meant ‘Drastically’ ;) (Dramatically is negative)