What are the benefits of an N-layered architecture

2019-07-11 02:00发布

问题:

What are the benefits of an N-layered architecture? How does that make an application better?

回答1:

From here:

  • Other applications will be able to reuse the functionality exposed by your layers.
  • You will be able to distribute your layers over multiple physical tiers. This can make a very good impact on your application by improving performance (sometimes), scalability and fault tolerance.
  • The maintenance of your application is easier because of the low coupling between layers.
  • Adding more functionality to your application is made easier.
  • Layers make your application more testable.
  • Building a well formed layers makes the orientation in your application more easier.
  • Having your application not layered means that you have to deal with all security threats in one place which is very difficult. Having your application distributed to layers makes it much easier for design and implement
  • Without a good deployment plan it is not trivial to distribute your layers over multiple physical tiers in distributed computing. You need to plan ahead your layers when you create a distributed application.


回答2:

Maintenance of and enhancements to the solution are easier due to the low coupling between layers, high cohesion between the layers, and the ability to switch out varying implementations of the layer interfaces.

Other solutions should be able to reuse functionality exposed by the various layers, especially if the layer interfaces are designed with reuse in mind.

Distributed development is easier if the work can be distributed at layer boundaries.

Distributing the layers over multiple physical tiers can improve scalability, fault-tolerance, and performance. For more information, see the Tiered Distribution pattern.

Testability benefits from having well-defined layer interfaces as well as the ability to switch out various implementations of the layer interfaces.

Summary

Benifits are

  1. Reuse of layers
  2. Support for standardization
  3. Dependencies are kept local
  4. Exchangeability


回答3:

Firs of all, layered architecture is a type of "Modular Design". Hence, in order to appreciate the benefits of layered architecture, one needs to know what modular design is. Secondly, it is a special type of modular design, specifically organized to manage dependencies in order to minimize tight coupling, thus achieving the objectives of modular design - autonomous modles/components. When we have autonomous/independent modules, then they can be reused, extended, tested, and so on, compared to the case where the architecture/design is not modular.

I have an article about layered architecture, where I discuss these things in more detail. It might be helpful.

Layered Architecture Explained