#article/done/published
#Architecture
#Three-tier fractal architecture
When studying architecture, various layered architectures are often encountered, such as traditional three-tier, four-tier, DDD, hexagonal, MVC, MVP, MVVM, etc., and there are constantly new layered methods emerging.
Do we really need to constantly learn so many layered methods? Is there a universal layered method that can be learned?
Architectural methodology - the three-tier fractal architecture attempts to use a methodology to generate applicable layered methods.
Why layering?#
The essence of layering is focus. Traditional three-tier focuses on business logic, MVC focuses on interaction flow control, ORM focuses on data mapping, and DDD focuses on domain services.
How to layer?#
First of all, the core of a software system is the business logic. By focusing on business logic, we have the first layer, the business logic layer.
Business logic cannot be directly used by users, so we need an interaction layer (or presentation layer, access layer) to apply the business logic.
Business logic cannot be built out of thin air, it needs support from other applications, so we also need a foundation layer (or data layer).
Do we need any other layers?
Currently, it is not necessary.
The foundation layer here is also the application of other systems. That is, the application of one system supports other systems, and the core of one system depends on the application of other systems. Because the relationship between systems and systems, and systems and users is nothing more than support and dependence, this already covers all cases.
What is the three-tier fractal architecture?#
So why does DDD have four layers, and networking has 7 layers, and so on, designs that exceed three layers?
Designs with more than three layers are actually based on the three-tier architecture, and one of the layers is refocused on a different core, resulting in a redivision of three layers.
For example, if the core layer refocuses on entities and aggregates, then the application domain entities will require an application service layer, and the support for domain entities will require repositories, domain event buses, and other support.
In the interaction layer, the focus is on interaction flow control. The core layer is the controller, the application layer is the view, and the support is the model. The focus is on different presentations of the interface. The core layer is the presenter, the application is the view, and the support is the model.
Three-tier architecture refers to focusing on a certain core and dividing it into three layers based on the relationship between support and application.
Three-tier fractal architecture refers to applying the three-tier architecture method in each layer and recursively applying the process. Because it is the repeated application of the three-tier architecture, it resembles a fractal, so it is named the three-tier fractal architecture.