Anti-pattern: horizontal slicing with n-tier architectures at large scales

Consider for example a 3-tier architecture involving three independently developed and maintained modules:

  1. Presentation tier: User interface
  2. Logic tier: functional process logic ("business rules")
  3. Data tier: Data storage and access
3-tier

This is sometimes called horizontal slicing and at large scales it's an anti-pattern.

The problem is that it is cross-cutting through the vertical domains which are far more cohesive and far less coupled than the horizontal slices.

By contrast the horizontal slices are tightly coupled. For example, if an extra attribute needs to be added, it needs to be added to every tier.

Adding more tiers doesn't improve things, actually it just adds more work when changes are required. When data is presented they are tightly coupled, adding more layers between them doesn't change that.

If the tiers are developed by different software teams, then it requires the teams to coodinate all the time. In extremely complex systems it is better for the software teams to specialise in vertical domains rather than require every team to have a detailed understanding of each and every vertical domain - i.e. the entire system.

When the emphasis is on vertical slicing (i.e. by domain) it's still important to separate data, function and presentation within a domain.

This is most easily achieved when the infrastructure associated with the horizontal slices supports composition. For example data schema composition, or UI composition.

vertical-slicing

As an example, data schema composition in a relational database is trivial - the set of relvars in the composite is the union of the sets of relvars from each domain.

Note that the idea that each microservice has it's own database is typically overkill and fortunately unnecessary (because it represents a lot of adminstration overhead, not to mention cost for licensing commercial DBMS products).

UI composition is for example achieved using tree, list, panel, stack controls etc.

Some other reasons to prefer vertical slicing: