It’s been more than a month now since I’ve posted. I’ve been really busy with project work, and moving to my new home. So let’s start off with a bang….
In almost every developer’s life, our effectiveness and productivity are greatly affected by the tools we use. I’m sure everyone has a list of developer tools that they love. I’m no exception to that, and I’ve recently added NDepend (which is a static analyzer that simplifies managing complex .NET code base) to my list of GREAT tools. Patrick Smacchia was kind enough to give me a professional copy of NDepend and I decided to use it with a sample project I’ve been working on slowly and painfully over the last month. I took the sample WPF application (using Prism v2) I posted some time back, and decided to convert it into a Multi-Target project with Silverlight using Project Linker (will blog about this later). I thought it would be a good idea to see how decoupled my solution would be using Prism and Multi-Targeting.
NDepend has a very large set of features, and for this post, I’m only able to scratch the surface of it’s capabilities and provide a high level view.
Upon starting up NDepend, I was struck by it’s clean UI and visually attractive look. After looking my numerous WPF and SL assemblies, NDepend immediately whipped up a report in HTML format (or generate one using F5) and displayed it on my browser. Navigating back to the NDepend UI, I decided to investigate the numerous features. I managed to find my way around relatively easily, without the need to read lengthy documentation or tutorials. That’s a sign of well designed UI and usability. Let’s move on to some of the features.
Metrics play an important part of measuring code quality. NDepend provides a very deep level of metric information. It’s not just about numbers but there’s also a interesting visualization medium. If you look at the screenshot above, you will notice that the assemblies are broken up into funky looking rectangles. If you mouse over these rectangles, the tooltip will tell you which class, and what method you are currently looking at. I really like this visualization effect since the size of the rectangles tell me straight up how large my assemblies are in the whole scheme of things, as well as the size of my classes. When you mouse over a rectangle, the Info windows shows you metric information for that class and method.
The dependency matrix shows you how tightly coupled your assemblies are, based on different units of measure. For instance, in the screenshot above, the matrix shows the number of method access from one assembly to another. Clicking on a cell will give you more detailed information about that coupling. Selecting the dropdown gives you different units of measure, like Types, Namespaces, Fields, etc. I have many zeroes, I guess that’s a good sign
The dependency graph is great at looking at the dependencies for each assembly. Again NDepend utilizes heavily on visualization, with very cool effects of highlighting these dependencies when you mouse over. This allows you to actually see how complex your application is (or has become, using compare different version of your code base).
Code Query Language (CQL)
This is my favourite feature of all. CQL bears great resemblance to SQL statements and makes sense to do so. Using CQL you can write to own queries to find retrieve your desired metrics. If you look at the screenshot above, out of the box there are CQL query groups that tell you about your Code Quality, Design, etc. All these “benchmarks” are constructed using CQL and you can drill down deeper to see the actual CQL query as well as the results of these queries. Of course you can modify these “benchmarks” to suit for project needs, or create new ones, using the CQL Editor, which has built-in compiler and Intellisense! Sweet.
Why I like NDepend
I really like the way NDepend uses visualizations instead of just dumping raw data on the screen. I also really enjoy the way information is displayed dynamically just by mouse-over and not having the need to always click to see information, like most other tools. Most importantly, I love how NDepend updates all the other windows accordingly when you select something in one of them, sort of like global updating.
If I had to pick one thing I don’t like about NDepend, it would have to be metric terms used, and the way it is calculated. For a beginner like myself, I do have trouble understanding what some of the terms refer to. For instance, something that confuses me is “Relational Cohesion 1.75″. It would be nice to have some kind of pop-up tooltip that tells me the definition of a term, and how good/bad that number is. Perhaps I have not dug deep enough and that feature may already be there, so please do correct me if that is the case.
In my opinion, NDepend is an excellent analyzer tool to ensure overall quality of your code base. Now there’s actually a product that can tell you how tightly coupled or complex your application really is. And best of all, you can put this information to good use, be it refactoring, redesigning or abstracting your code base. With NDepend, there is no longer an excuse to not to pay off your technical debt, before bad things happen!
Don’t just take my word, do conduct your own analysis of NDepend, and see if it suits for needs. If you would like to see the NDepend report I mentioned earlier in this post, you can download that report here. There’s a great level of detail! Enjoy.
|Share this post:|