Saturday, July 4, 2009

Inspect Xaf code quality and override version migration problems using NDepend

NDepend is the most wonderful analysis tool I have ever found . It can help you by providing metrics of your code or anyone else  code, specify code constrains, analyze code, diff between versions of your code.  It also has an open source license to anyone interested.  I am going to apply the some metrics like the ones Patrick posted here

http://codebetter.com/blogs/patricksmacchia/archive/2009/05/21/a-quick-analyze-of-the-net-fx-v4-0-beta1.aspx http://codebetter.com/blogs/patricksmacchia/archive/2009/04/26/the-big-picture-of-the-sharpdevelop-code-base.aspx
http://codebetter.com/blogs/patricksmacchia/archive/2009/04/23/ndepend-and-the-quality-of-the-cruise-control-net-code-base.aspx
http://codebetter.com/blogs/patricksmacchia/archive/2009/01/11/lessons-learned-from-the-nunit-code-base.aspx http://codebetter.com/blogs/patricksmacchia/archive/2009/01/19/mono-vs-net-framework-public-api-compatibility.aspx http://codebetter.com/blogs/patricksmacchia/archive/2008/10/01/comparing-silverlight-and-the-net-framework.aspx http://codebetter.com/blogs/patricksmacchia/archive/2008/08/26/nhibernate-2-0-changes-overview.aspx http://codebetter.com/blogs/patricksmacchia/archive/2008/08/13/net-3-5-sp1-changes-overview.aspx

in to Xaf 1.5.4

I am very interested to know how serious DevExpress is taken code quality . From my experience, I mean from digging their source every day I say they are good but lets find exactly how good they are.

In the right view you can see one of the many NDepend views that help you to visualize your analysis, and from just a look we can see that in this query a very small part of the framework is involved (where color is blue)

Field Analysis

  • Number of Fields
image image

Method Analysis

  • Number of methods

image image

ok !! same results

  • Number of Lines of code >25
image image

For this one I think that maybe someone should start put some more rules to their team

  • CyclomaticComplexity >15
image image

aha!!! Here we start to see how much NDepend Rocks!!! (see right picture) .Almost 3 times better than previous metric. Good work on this one.

  • Poorly commented
// <Name>Methods poorly commented</Name>
// A method with at least 10 lines should be commented.
WARN IF Count> 0 IN SELECT METHODS WHERE
PercentageComment < 20 AND NbLinesOfCode > 10

image

NONE!!! excellent!!!

  • With parameters count>5
image image

You see by just looking the right image you can tell if the metric is applied or not even if the image has small resolution

  • With local variables count > 7
image image
  • Better encapsulation
image image

Types Analysis

  • Inheritance tree depth >5
image image

Interesting !!! I didn’t expect to find so many types

  • Number of fields > 10
image image

that is a bad one

  • Types that use boxing
image image

another bad one

  • Better encapsulation
image image

Most powerful eh? what do you think? NDepend features do not stop here!!! they are endless.

lets see how the above statistics vary through time, by getting the diff between 9.1.2 and 9.15 version

image

Ok nice info but we can do better than that.

We Can find all types that added or changed since 9.1.2 version

image

Version migration

And something even more powerful, you can tell with ease if your application that you have build with 9.1.2 with hold a 9.1.5 version migration by using NDepend’s CQL language to ask “if there are methods that used to be public and for which visibility was changed or have been removed

image 

very powerful tool!!! You should try it.

ps: I should say a very big thnks to NDepend that has offered a free pro license to all contributors of eXpand

Subscribe to XAF feed
Subscribe to community feed

DiggIt!

0 comments:

Post a Comment