Patrick Smacchia [MVP C#]

Sponsors

The Lounge

Advertisement

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.

 


Posted Sun, Mar 29 2009 12:13 PM by Patrick Smacchia

[Advertisement]

Comments

Frans Bouma wrote re: Dramatically leverage your Code Reviews
on Sun, Mar 29 2009 10:16 AM

I think you meant 'Drastically' ;) (Dramatically is negative)

Jason Haley wrote Interesting Finds: March 29, 2009
on Sun, Mar 29 2009 11:18 AM
DotNetShoutout wrote Dramatically leverage your Code Reviews - Patrick Smacchia - Code Better
on Sun, Mar 29 2009 11:46 AM

Thank you for submitting this cool story - Trackback from DotNetShoutout

Patrick Smacchia wrote re: Drastically leverage your Code Reviews
on Sun, Mar 29 2009 11:54 AM

Thanks Frans ;o)

Kevin Stevens wrote re: Drastically leverage your Code Reviews
on Mon, Mar 30 2009 9:59 AM

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.

Patrick Smacchia wrote re: Drastically leverage your Code Reviews
on Mon, Mar 30 2009 10:19 PM

Kevin, thanks for this english point

Patrick Smacchia [MVP C#] wrote Ship It Often vs. TDD
on Fri, Apr 3 2009 11:49 PM

Ayende recently answered the question what the bare minimum aspects of Agile project would be? His opinion

Patrick Smacchia [MVP C#] wrote Efficiently Searching Code Elements by Name
on Mon, Apr 6 2009 12:29 AM

Normal 0 false false false EN-US X-NONE X-NONE What the tremendous success of Google told us is that

Add a Comment

(required)  
(optional)
(required)  
Remember Me?