The need for decoupling
The clean architecture works well for any programming language. Once the domain layer is defined, the application layer can build on that. The internals of the domain layer are placed in methods, and the methods can be used in the application layer. A method in above example could be registerNewRenter(Person person)
of the House
class. What exactly is happening inside that method is hidden from the application layer. Only when the footprint of the method changes does this have impact on all classes in the application layer that use the method. Luckily do footprints of methods change much less frequently than the internals of the method.
In Blueriq is everything included in an interaction module. This means that your flow has access to each and every element in the domain of the domain layer. This is in principle correct, and adheres to the dependency rule of the clean architecture. What this however implies, is that changing any element of the domain layer may have an impact on the application or interface layer. This was not your intention however, as you also expose internals to the higher layer. In any object oriented programming language, you expose a method or interface to another class, but not the inner working of the method. In Blueriq there are no methods, meaning that all internals are exposed, and can be seen as method or interface. Even though this adheres to the dependency rule, this is much more than intended or needed. As a result, before changing any small thing an impact analysis needs to be performed. This can be achieved by using the dependencies in studio. Having to do this for every element is however a tedious job, and mistakes are bound to happen. This leads to:
- Additional work to check for the impact of every change
- People being scared to make changes
- A preference for creating new attributes above reusing/refactoring old ones, cluttering the domain
- An overflow of elements in studio, which reduces the working speed and increased the mental load
It would be great however if you can know for sure what elements can be changed without any impact on the higher layers, and which ones should be changed with care after an impact analysis. What we essentially want to achieve is that only a small set of elements has this dependency (you can also say that it is coupled), and you can quickly and easily change all other elements. This small set of elements can be regarded as the method footprint if you think of it as code. This leads to
- Quicker development
- Better test-ability
- Confident business engineers
The core of Blueriq is its knowledge modelling capabilities. That is what most time is spent on, and delivers most value to our customers. This functionality is in the domain and application layer. We have to integrate to external systems, but that is all abstracted away in the model, with a simple service type. There are also no details on how the front-end is creating a running page, only an abstract definition of what should be placed on a page. So you envision the outer two layers, the interfaces and adapters layer as rather thin in the Blueriq model, as shown on the right.
When a layer boundary is crossed, then this is a good opportunity for decoupling. The adapters layer sole responsibility is to decouple the center of the onion with outer layer. As the center of the onion is so large in Blueriq, there actually is also a need for decoupling when staying in the same layer. For example, lets say a calculation for the maximum lease amount of a car is dependent on the risk score of a customer. Both of these numbers are part of the domain layer. You may however want to decouple each calculation so that all internals of a single calculation may be refactored and maintained easily, and are not 'in the way' when working at other parts of the application. So, to summarize, the application of decoupling can be split up into two categories:
- Decoupling to prevent layers blend into each other.
- Decoupling to expose functions within the same layer.
The next section of this guide describes concrete patterns of how this can be achieved: 4. Patterns