A software architectural pattern that divides the system into horizontal layers, each providing service to the layer above it.

  • Lower layers and hidden from upper layers


Variants

  1. Relaxed layer system Some of the strict rules of the layered architecture are relaxed for increased flexibility and performance
    • A layer can use services from any of it’s lower layers not just the immediate
    • Layers can be partially opaque
  2. Layering through inheritance Upper layers can optionally override service offered by lower layers

Usage

  • OSI Architecture
  • Virtual machines - JVM has layers for binary byte-code format, runtime, and Java libraries.
  • APIs - Provide an encapsulation layer over lower level services.
  • Information systems - UI, business logic, data access layers.
  • Windows NT - Has systematic layers for services, resource management, kernel, hardware.

Benefits

  • Reuse - Layers can be reused across applications.
  • Interchangeability - Layers can be swapped via adapters or bridges.
  • Standardization - Layers enable standards compliance.
  • Localized dependencies - Only on the next lower layer.

Drawbacks

  • Reduced efficiency - Each layer adds overhead.
  • Cascading changes - Modifying lower layers affects upper layers.
  • Finding right layer granularity - Too few or too many layers causes problems.

Example

In a simple web application, you might have a presentation layer responsible for the user interface, a business logic layer handling application logic, and a data access layer managing interactions with the database.