Layered Architectural Design Patterns
Layered patterns which focus on separating designs into distinct areas of concern to group classes and components toghether.
There are specific rules to which we should stick to when working with Layers.
- A Layer is only allow to communicate with layers immediately above or below.
- All the layers should follow the same architecture design, different design patterns should not be mixed in the same layer.
- All the elements of the layer should be semantically related.
- If there is a components to which all the layers need to have access they should access to a global component.
- Distinct client and server
- Separated by network
- Communication protocol
- Many clients, one server
|Simple Communication||Difficult to scale out|
|Centralized control||Single Point of failure|
|Easy to manage||Hard to debug|
Lowe layers need to be super flexible because they will serve to upper layers.
- Strict areas of concern
- Communication is only to immediate neighbors.
|High isolation||Can hide complexity|
|High abstraction||Deep call chains|
|Structured Communication||May harm performance|
|Easy to scale out||Lowest layer must cover all use cases|
Similar to Layered Pattern but each of them is deployed onto different machines.
- Layers deployed to servers
- Usually 3 Tiers
- Communication between layers uses network
|High abstraction||Network = Point of failure|
|High isolation||Network may be slow|
|Structured communication||Coarse interfaces|
|Easy to scale out||Hard to debug|
Logical Layered Design
Define Layer Interfaces
Alternatives: Singletons, Command Pattern, Dependency Injection, Message-based,…