Programming an n-Tier Architecture Design Pattern

n-Tier Architecture provides a pattern which developers can create reusable applications by separating database from logic and presentation.

By Tim TrottSoftware Engineering • August 4, 2010
Programming an n-Tier Architecture Design Pattern

In software engineering, multi-tier architecture (n-tier architecture) or multilayered architecture is a client's server architecture in which presentation, application processing, and data management functions are physically and logically separated. It allows a web presentation layer to run on a web server, whilst the business logic and database could be on a different layer, even a different network behind a firewall.

N-tier application architecture provides a model by which developers can create flexible and reusable applications. By segregating an application into tiers, developers can modify or add a specific layer instead of reworking the entire application. A three-tier architecture typically comprises a presentation, domain logic, and data storage tier.

Multi-tier archetecture
Programming an n-Tier Architecture Design Pattern

Presentation Layer - n-Tier Architecture

At the top of the diagram, we can see various application types. This is the presentation tier, and these applications are responsible for only performing the functions to gather and display information. If required to perform calculations and store or retrieve data, they must interact with another layer, the business logic layer.

Business Logic - n-Tier Architecture

Business logic is usually a separate assembly or web service that provides a common place for any logic to be performed. This includes calculations, data retrieval and data storage. If this tier requires storing or retrieving data, then it, in turn, calls on the data access tier.

Data Access Tier - n-Tier Architecture

The data access tier is only concerned with storing and retrieving data from a data source. At the bottom of the diagram, we can see various data sources, such as XML, SQL, and JSON, in this example. However, these can be any source of data. The data access tier is used to query these data sources and return the results to the business logic tier.

Business Objects and Data Transit Objects (DTO)

Business Objects and Data Transit Objects (DTOs) transport data between the layers. DTOs are usually used when transporting data from the Data Access layer, which will map a Data Entity object specific to the database (e.g. an Entity Framework) to a common object shared between the business logic and any other data access layers. The business logic layer will perform any business rules and present a business object to the presentation layer. The business objects are common to all presentation layers.

n-Tier Architecture

Using this architecture, the presentation tier is not concerned with retrieving data or data entities, meaning that upgrades or extensions to the presentation can be performed quickly. It also means that multiple applications (websites, mobile applications, desktop applications, web services, and so on) can use the same business logic and data access without code duplication, resulting in consistent results across applications.

Another advantage of n-Tier Architecture is that separate teams can work on each tier once a standard interface is agreed upon. This allows web developers to develop web applications, database application developers to develop data access, Windows Forms developers to build applications, etc.

About the Author

Tim Trott is a senior software engineer with over 20 years of experience in designing, building, and maintaining software systems across a range of industries. Passionate about clean code, scalable architecture, and continuous learning, he specialises in creating robust solutions that solve real-world problems. He is currently based in Edinburgh, where he develops innovative software and collaborates with teams around the globe.

Related ArticlesThese articles may also be of interest to you

CommentsShare your thoughts in the comments below

My website and its content are free to use without the clutter of adverts, popups, marketing messages or anything else like that. If you enjoyed reading this article, or it helped you in some way, all I ask in return is you leave a comment below or share this page with your friends. Thank you.

There are no comments yet. Why not get the discussion started?

New comments for this post are currently closed.