Layered Architecture for Architecture Design

In architecture design, we often hear layered architecture, so what exactly is layered architecture?

First of all, we have to understand the concept of layers. Layers are logical units of software. Each layer solves a specific problem. For example, the 7-layer architecture of HTTP. There is also the spring mvc architecture that we often hear about. These are all layered concepts. There is also the controller service do we have come into contact with during the development process. These are all layers in the layered architecture. Perhaps speaking of this, you will have a deep understanding of the concept of layers. There is an unwritten rule in the computer field. Just add another layer to the problem that cannot be solved. Just like adding a virtual layer to the JVM virtual machine, it solves the difference at the hardware level. So layered architecture plays a very important role in our architecture design. Good use of layered architecture can make the architecture very clear. And the code can also be extended well.

1. Our system architecture is generally divided and organized according to responsibilities. After dividing the responsibilities, it can be designed and implemented according to the layered architecture. So what are the advantages and disadvantages of layered architecture in architecture design?

The advantages are as follows. Since each layer only solves one problem, the whole architecture has good high cohesion, low coupling, and good scalability in each layer. It's also very maintainable and testable, because you can maintain and test only for each layer and don't worry about the other layers. Layers interact with each other through interfaces. Because relying on the interface is equivalent to relying on abstraction rather than implementation, the overall change is very small.

Now that we have finished talking about the advantages, let's talk about the disadvantages. An obvious disadvantage of the layered architecture is that as the number of layers increases, the communication time will increase. The performance of the overall architecture is not particularly high.

2. We said what is a layered architecture, and explained the advantages and disadvantages of the architecture, so how do we implement a layered architecture?

Generally, when we do system design, we start from the web controller entity, from the outside to the inside, and the more we go in, the more abstract it is. The interior of the system is often the embodiment of some rules. So each layer only needs to pay attention to its own affairs. Just like the web layer only focuses on user interaction, the controller layer only focuses on request forwarding. Under the hood is some implementation.

Guess you like

Origin blog.csdn.net/summer_fish/article/details/131284219