Layered Architecture
Definition
The most common architectural pattern, layered architecture, focuses on the concept of layering for developing systems. Modules or components with similar functionalities are organized into multiple horizontal layers, where each layer plays a specific role in the whole system and contributes to the operation of the layer above it.
The pattern doesn’t define a fixed number of layers (or types) and leaves it upon the preferences of the architect, or developers.
Layered architecture abstracts the view of the system as whole while providing enough detail to understand the roles of individual layers and the relationships in between them.
Description of the Pattern
In a layered architecture, each modular layer depends on the layers beneath it and is completely independent of the layers on top of it. In this way, these layers can be used strictly, where the layer only knows of the layer beneath it, or in a flexible manner, and access all layers beneath it.
This brings us to the concept, layers of isolation. By definition, the changes made in one layer of the architecture generally don’t impact or affect components in other layers: the change is isolated to the components within that layer, and possibly another associated layer.
Most layered architectures consist of four standard layers: presentation, business, persistence, and database. These four layers could vary for complex applications.
Separation of concerns among components is the best feature of the said architecture. Components within a specific layer deal only with the logic that pertains to that layer. For example, components in the presentation layer only deal with the presentation logic. This makes it easier to build effective roles and responsibility models into the architecture and make subsequent phases of development way easier.
Advantages of this architectural pattern are:
· Layers make reuse easier.
· Dependencies between layers are minimized.
· A layer can easily be swapped with a different implementation without a system failure.
· Development is fairly easy.
· Testing each component becomes easier.
However, the liabilities of the said architectural pattern are as follows:
· Stacking of layers increases size and processing time.
· Lends itself to monolithic applications despite layering.
· Logical coupling across distributed environments reduces the technological independence that was introduced.
Applications of the Pattern
- OSI model
Open Systems Interconnection (OSI) model is a conceptual framework that describes the functions of a networking or telecommunication system, and implements protocols in seven layers.
The OSI model divides network communication into seven layers. Layers 1–4 are considered the lower layers, and mostly concern themselves with moving data around. Layers 5–7, the upper layers, contain application-level data. Networks operate on one basic principle: “pass it on.” Each layer takes care of a very specific job, and then passes the data onto the next layer. (World, OSI Model)
Layers can be different sizes, hosting different numbers of protocols. Changes to a layer affect only that one layer. In other words,
the communication protocol chosen at a lower layer doesn’t affect the functionality provided at its higher levels. You’re free to pick and choose the protocols to use in each layer.
2. Web applications
Web Applications most commonly use a three-tier architecture (tiers being the layers). These layers are divided into the presentation layer, followed by the business logic layer and finally the database layer in the bottom. Each layer is given a distinct functionality, for example:
1. The presentation is the interface between the user and the web server.
2. The business logic layer processes requests from the presentation layer and acts as a medium for interaction between the presentation and database layer.
3. Database layer manages the persistent data and supplies that to the other layers
3. Adapting to new hardware
Operating systems are examples of layered architectures as they start with the central kernel and surrounded by layers of functionality, such as device drivers and middleware.
The layered architecture makes adapting to new hardware easier, because only the device drivers need to change when a new device is added.