Software Architecture Patterns — Layered Architecture Patterns

Yap Wen Jun Bryan
5 min readOct 25, 2020

--

Which software architecture pattern to use to design your new software is one of, if not the most, important question to answer during the planning phase of developing new software. The architecture of the software decides the components of the software, their properties as well as the relationship between them.

One common software architecture pattern that you may have heard of is the layered architecture pattern. In general, the layered architecture pattern consists of 4 different variations, 1-tier architecture, 2-tier architecture and n-tier architecture. In this tutorial, we will be covering 1-tier architecture, 2-tier architecture and 3-tier architecture, as well as the advantages and disadvantages of each of these variations.

Before we begin, let us take a quick look at the 3 general layers, presentation layer, application layer and data layer, that a software application will have.

Diagram of the three layers commonly found in a software

Presentation Layer

The presentation layer is the topmost layer of a software and represents the UI components and what the user sees when using the software. User actions such as button clicks are then passed from this layer to the next layer, the application layer. An example of a presentation layer of a software application would be the sign-up page and button on Facebook which sends information to the application layer to process the sign-up request.

Application Layer

The application layer, also sometimes known as the logic layer or the business logic layer, processes and carries out user requests and is the layer that determines the functionality of a software. As it usually requires interactions with the data layer to complete user requests, it can also be thought of as the layer that connects the presentation layer and the data layer. Using the example of Facebook sign-up, the application layer will hold the sign-up logic which processes the user’s sign-up request and adds the user to the database.

Data layer

The data layer is where the database of the software is found in. Using the example of Facebook sign-up, the data layer will house the database of users that Facebook has and would add a user into the database upon receiving a sign-up request from the application layer.

Let us now look at the 3 different variations of the layered architecture.

1) 1-tier architecture

In the 1-tier architecture, every layer of the software is merged into one and resides in the client. All components are found on the same platform/ server. An example of a software application that uses such an architecture would be Microsoft Excel. In Microsoft Excel, the presentation, application and data layers are all found on the same platform, which in this case is the user’s computer.

All three layers are merged into one in a 1-tier architecture

Advantages:

1. There is no additional overhead in processing user requests as all three layers are merged into a single layer. This allows for faster processing of user requests as no communication has to be done with another system.

2. Due to only having one merged layer, there will not be any compatibility issues that a multi-tiered architecture might face.

Disadvantages:

1. Only one user can use the software on a local machine at any given time. This limits the number of users that can concurrently access the software.

2. Due to the monolithic nature of such software, it is difficult to maintain and scale when the software gets bigger.

2) 2-tier architecture

The 2-tier architecture can be seen as a Client-Server model. Similar to the 1-tier architecture, the presentation and application layers are merged into one layer. However, unlike the 1-tier architecture, the data layer in the 2-tier architecture is not merged together with the presentation and application layer and resides independently from the other two layers. The UI and business logic resides on the client while the database resides on the server.

A possible arrangement of the layers in a 2-tier architecture

Do note that the business logic of the software can also be placed in the server together with the database so that performance can be optimized due to the close proximity of the business logic and database.

A simple example of a software that utilizes a 2-tier architecture could be a company’s Human Resource portal which allows admins to add and retrieve employee’s information from a database in the companies server. The portal itself would make up the presentation and application layer while the database makes up the data layer.

Advantages:

1) Multiple users can use the application at the same time due to having separated the client and server-side.

2) Allows for flexibility where the application layer can be either placed in the client-side or the server-side based on the needs of the software.

Disadvantages:

1) As more clients are added, more servers may need to be added in order to serve the increase in the number of clients. This results in higher costs as well as a more difficult time maintaining the multitude of servers.

2) If no additional servers are added as the number of clients increases, the performance of the software may suffer due to the increase in the number of requests that the single server has to process.

3) 3-tier architecture

In a 3-tier architecture, each layer resides independently from other layers. No merging of layers is done in this architecture and the three layers are clearly separated from one another. A simple example of a software that uses a 3-tier architecture could be a web-based e-commerce application such as amazon where the presentation layer is deployed to the user’s device while the application layer and data layer reside independently on separate servers.

Decoupling of the layers in a 3-tier architecture

Advantages:

1) Decoupling the layers allows for better scalability and easier modification to the individual layers.

2) The different layers can also be developed and deployed independently due to being decoupled from one another.

Disadvantages:

1) Increase overhead in communication between different layers due to each layer residing independently from one another.

2) Increase in complexity of structure as compared to tier-1 and tier-2 architectures. Maintaining all three layers will require more time and effort.

As shown above, each variation of the layered architecture has its own advantages and disadvantages. It is therefore important to understand the requirements of your new software well in order to pick out the best variation to implement your new software with.

References:

Ian Sommerville (2016). Software Engineering (10th ed.)

--

--

Yap Wen Jun Bryan
Yap Wen Jun Bryan

Written by Yap Wen Jun Bryan

0 Followers

A computer science undergraduate in the National University of Singapore

No responses yet