Geeks With Blogs
Late bound thoughts about problems (and possible solutions)

It is no big news that whatever the architecture you plan and implement, soon or later you'll start to see some code "bad smells". In the early phase of implementation you might do some team training and explain how your developer team should write code using the planned architecture and design (patterns). Despite this effort, you cannot expect people to just follow your implementation recommendations every time.

At first, you might consider using gated-checkins or CI builds with VS code analysis. The problem with this approach is that you cannot accurately see what is changing or braking in your architecture so this is not enough.

The solution is: use an architecture and design visualization tool!

I am a total C# and .NET lover so the tool I would recommend and will talk about is NDepend.

This tool has direct integration with Visual Studio (2005, 2008 and 2010) and can be a great replacement for Visual Studio's integrated Code Analysis.


It not only allows you to graphically see your dependencies in code using a Dependency Matrix or Dependency Graph but also allows you to query your code using CQL (Code Query Language):

CQL - Code Query Language

Let's say you are implementing the MVP pattern (passive view) and don't want anyone referencing concrete view types in the presenters. You would just write the following CQL:

WARN IF Count > 0 IN SELECT TYPES FROM NAMESPACES "AgnosticApp.Presenters.*"
WHERE IsDirectlyUsing "AgnosticApp.Views.*"

The CQL language gives you an easy way of creating code validation rules and the Visual NDepend editor has Intellisense-like dropdown hints that appears while you're writing code.

The report you get gives you very detailed information regarding Dependencies, CQL Rules violations and Code Metrics (over 82 metrics). You can even define a baseline and get Diffs between analysis runs!

Ohh almost forgot! You can even integrate it with FinalBuilder!



Posted on Wednesday, June 8, 2011 8:44 PM | Back to top

Comments on this post: Fighting Architecture and Design Erosion

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © tiagomargalho | Powered by: | Join free