Software Design - An Approach
June 15th, 2022
In this article I will detail an approach to creating a high-level structure for software that works for me. I believe this may be useful for others as well.
Five high-level responsibilities
I have found that there are five high-level responsibilities. Every application that does something useful has these responsibilities in some form or shape. They are:
- Domain
- Infrastructure
- Orchestration
- Construction
- Start-up
Domain
The responsibility of domain-level code is to express the rules (invariants) and data of the domain. This is also sometimes referred to as the business layer, or logic layer. Domain-level code is expressed in terms that are familiar to those working in the domain.
Infrastructure
The responsibility of infrastructure-level code is to send domain-level objects to infrastructure components or retrieve domain-level object from infrastructure components. Infrastructure components interact with the outside world, such as file systems, databases, web services, etc. The user interface is also considered infrastructure.
Orchestration
Orchestration-level code is responsible for controlling the flow between the various domain objects, infrastructure components and other orchestration components. This is sometimes also known as the application layer.
Construction
Construction-level code contains all the knowledge to build the infrastructure components and orchestration components, and their scope. This may also be known as the composite root.
Note that domain objects are either created in domain-level code itself (in case of new domain objects), or recreated from infrastructure in infrastructure-level code. Therefore, the creation of domain-level objects is not considered construction-level code.
Start-up
Start-up level code is responsible for executing the necessary steps to start and run the application. This is also known as program entry.
Complexity arises when these responsibilities are being mixed. Many problems, bugs and other difficulties in code that I have seen over the years can be attributed to code with confusing high-level responsibilities. Therefore, it is a good idea to separate these responsibilities.
-- Rene Wiersma