Used for applications that can be organized into a hierarchy of layers. Each layer provides services to the layer above and uses services from the layer below.

Components

  • Layers: Each layer groups components at an abstraction level (domain, data, infra, etc)
  • There is dependancy between layers
  • Connectors are method (or RPC) calls across layer boundaries behind interfaces
  • Communication happens between adjacent layers

Pros and Cons

Pros:

  • Since each layer is decoupled, it is possible to swap implementations within a layer if the contracts are kept.
  • The system is easy to understand due to abstraction Cons:
  • Abstractions can add overhead, and performance requirements could force coupling
  • Not all systems map cleanly to these structures

Variants

Allowing non-adjacent layer communication

  • This just allows a higher layer to call a lower layer directly but things like this tend to erode boundaries. An important example here is the architecture of UDP