Logical Architecture Models

With Sonargraph 9.7 our architecture DSL gets a new feature: logical models. Up to 9.7 the concept of a component (the smallest unit assignable to an architectural artifact) was based on the physical layout of your project. So components in a physical model are based on source files and their relative location in the file system. In a logical model components are the top level programming elements in a namespace or package and their name contains the namespace and no relative path.

In Java the physical and logical architecture models are almost identical since the package structure is reflected in the physical layout of a project. The only difference occurs when a Java file contains more than one top level type. In that case there would be one component for every top level type in the logical model, while there would be only one component for the Java file in our traditional physical model.

Therefore the logical model is much more suitable for languages like C# and C++ where there is no enforced relation between namespaces and the physical location of source files.

The following example from a real C++ project should explain the difference. The open source project “POCO” is organized in several modules. Each module has a single source root directory and one root directory for public include files. All C++ source files of that project are flat in the source root directory. C++ namespaces are used but not reflected in the physical organization of the project.


As you can see in the “Properties View” on the right the architecture filter name of the component “AbstractBinder” is “Data/AbstractBinder”, i.e. the module name followed by the name of the component. There is nothing in between because the component is directly located in a source root directory.

If we switch to a logical model the situation changes:

Now the filter name is “Data/Poco/Data/class Abstract Binder”. Between the module name and the component name we have the namespace of the class. This enables you to base the architectural assignment of the component on its namespace name.

To base your architecture on a logical model the first statement in your DSL description must be

model "logical"

If you want to use our traditional physical model you can either write

model "physical"

or omit the model statement completely.

As always please leave questions or comments below.

Leave a Reply

Your email address will not be published. Required fields are marked *