Chapter 11.  Defining an Architecture

Sonargraph 8 and higher allows the definition of an architecture as code via a Domain Specific Language (DSL) that is expressive and readable enough so that every developer is able to understand it. The graphical representation in Sonargraph 7 allowed the creation of your architectural blueprint in one single diagram. This leads to potentially very big and complex diagrams that are difficult to understand.

The requirements for the new DSL approach were the following:

  1. It should be possible to describe an architecture in a set of files. Some of them should be generic enough so that they could be reused by many projects, e.g. a generic template describing the layering of a system.

  2. It should be possible to describe an architecture in form of several completely independent aspects. E.g. one aspect describes layering, another aspect describes components and a third aspect looks at separation of client and server logic.

  3. On the other hand the language should also be powerful to describe the complete architecture in a single aspect.

  4. The DSL must be easy to read and easy to learn.

  5. The restrictions for dependencies should allow also the specification of dependency types (e.g. "new", "inheritance", etc.).

To create an architecture description you select "New Architecture File..." from the menu "File/New...". That will open an editor window where you can work on your architecture description. You can have as many architecture files as you like. To enable Sonargraph to use your description to check for architectural violations you also must add your architecture file to Sonargraph's architecture check. This is done in the "Files" tab of the navigation view by right-clicking on your architecture file and select "Add to Architecture Check..." from the context menu. If you later decide to remove the file from Sonargraph's architecture check you can also do this over the context menu.