Software Architecture Patterns

3 min read Original article ↗

Layered Architecture

Anuradha Wickramarachchi

This is the most common architecture pattern in most of the enterprise level applications. This is also known as the n-tier pattern, assuming n number of tiers. This is the de-facto pattern for JAVA EE applications.

Example Scenario for Layers

Press enter or click to view image in full size

Source: https://www.oreilly.com/ideas/software-architecture-patterns/page/2/layered-architecture

Presentation layer

Presentation of the web pages, UI forms and end user interracting API’s

Business layer

The logic behind the accessibility, security and authentication happens in this layer. This includes ESB (Enterprise Service Buses), middle ware and other various request interceptors to perform validations.

Persistent layer

This is the presentation layer for the Data. This includes the DAO (Data Access Object) presentation, ORM (Object Relational Mappings) and Other modes of presenting persistent data in the application level. In more meaningful words this demonstrates the persistent data in RAM. Which usually stays in Disks at the below layer.

Database layer

Simple Databases expanding up to SANs (Storage Area Networks)

Composition of Layers

Layers consist of components. These components are at a more abstract level than that of object classes and packages. A component may demonstrate a set of packages that perform a single task.

“Components enforce the separation of concerns”

Key Concepts

Closed Layers

This demonstrate the concept of Layers of Isolation which separates each layer in a more strict manner allowing only a sequential pass through layers without by-passing. As the diagram demonstrates this enforces better de-coupling of layers making the overall system more viable for changes.

Press enter or click to view image in full size

Source: https://www.oreilly.com/ideas/software-architecture-patterns/page/2/layered-architecture

Open Layers

Open layers allow the system to by-pass layers and hit a below layer. This is done in mission critical systems where the latency can cost a lot. Usually the layers implies the communication overhead. Thus at times it is reasonable to by-pass layers and directly seek data from the right layer.

Press enter or click to view image in full size

Source: https://www.oreilly.com/ideas/software-architecture-patterns/page/2/layered-architecture

An analysis on pattern

Adoption of the layered pattern may misguide and lead to an anti pattern called “Architecture sinkhole anti-pattern” which demonstrate having layers that do not perform any logic, yet add the communication overhead. Thus the layers must be designed in a manner that performs a specific task that compensates the communication overhead and maintainability of the overall system.

Pattern Testability

This is higher due to the layered nature. Each layer can be tested individually by passing dummy messages and having dummy interfaces to demonstrate immediate layers.

Performance and scalability

This could be low due to having the communication overhead. This might require conversion of message types and etc. Adding more layers is not a choice when it comes to scalability. The pattern will not scale infinitely.

P.S.
Despite the ups and downs the development effort is quite less since, once the communication protocols are identified different teams could work on layers and divide the components among members of each of the teams.