Concepts

Dependency rules and builds

.NET Architecture Checker reads one or more .NET assemblies and extracts all the uses of classes, structs, enums, delegates, inner classes, and methods from that file. It also needs a definition of dependency rules—here are two simple examples:

    MyProgram.** ---> YourLibrary.**
    MyProgram.** ---! System.Windows.Forms.** 

The two asterisks ** are the abbreviation for "a class name, including a namespace." The two rules thus mean:
All classes (and enums, methods, ...) in and below the namespace MyProgram may use all classes (structs, delegates, ...) in and below the YourLibrary namespace.
All classes (etc.) in and below the namespace MyProgram must not use any class (etc.) from the System.Windows.Forms namespace tree.
The idea is that rules like these are defined by the software architect(s) and checked every time a build is run. When rules are violated, .NET Architecture Checker will write something like the following and return with exit code 3:
    **** Illegal dependency MyProgram.MyClass/NestedClass::.ctor ---> SomeOtherLibrary.Class
        (probably at src\MyProgram\MyClass.cs:80) 


A violation of the rules should be like a compile time error: It breaks the build. Hence, a defined (static) software architecture can no longer degrade to some tangled web of dependencies, which will become unmaintainable over time.

Showing dependencies graphically

.NET Architecture Checker can also produce a DOT graph showing dependencies. This is not as useful as it sounds to most people: Defining and checking dependency rules should be the predominant goal. However, there are two applications for this feature:
  • First, and more important, it can be used to demonstrate and teach an existing good software architecture to people on a project.
  • Second, in existing projects with unknown dependencies, it can help to find the dependency structure and violations of perceived dependency rules. This, in turn can lead to a formulation of dependency rules to be adhered to, which can from then on be checked with .NET Architecture Checker. An example of this use is given below.

Last edited Jun 21, 2010 at 7:19 PM by thoemmi, version 2

Comments

No comments yet.