Experienced developers who use design patterns make usually this intention ex- plicit by some kind of documentation. For instance, leaving a note ”this class is immutable” in an API documentation may prevent the other developers in a team from making the class mutable, or the fact that another class implements the Composite pattern may direct the developer to implement a new operation by delegating it to a collection of components, which should be present in the Composite class.

An information about implemented pattern can also be helpful when a new developer in the team tries to understand the overall architecture of the software project. Some design patterns usually represent an infrastructural detail rather than a domain specific code. On the other hand, if we also consider the patterns used in the Domain-driven-design approach, these are mainly represented by domain specific classes, which are important for an overall picture of the architecture.

Unfortunately documentation in natural language is not understandable for software, but some kind of standardized documentation of design patterns implementation would be. The main conception behind the Patterns4Net is that developers will annotate their code using .NET attributes mechanism and the Patterns4Net will provide tools that will take advantage of this documentation and will support the development process.

Patterns4Net provides two main tools. Pattern Enforcer verifies some of the structural aspects of selected design patterns implementation and Architecture Explorer generates interactive UML-like class diagrams from .NET assemblies. This tool uses the information about design patterns implementations to generate more abstract and high-level diagrams than standard UML reverse engineering tools.


Pattern Enforcer


using Patterns4Net.Attributes;

public class WidgetComposition : IWidget, ICloneable
  private IList<IWidget> children;

  public int Width {
    get { return 0; }

  public int Height {
    get { return this.children.Sum(x => x.Height); }

Visual Studio shows Pattern Enforcer errors as warnings


Architecture Explorer

Architecture Explorer screen shot

Last edited Sep 12, 2011 at 7:15 PM by stevesindelar, version 11