Programming an n-Tier Architecture
In software engineering, multi tier architecture (often referred to as n-tier architecture) or multilayered architecture is a client–server architecture in which presentation, application processing, and data management functions are physically separated.
N-tier application architecture provides a model by which developers can create flexible and reusable applications. By segregating an application into tiers, developers acquire the option of modifying or adding a specific layer, instead of reworking the entire application. A three-tier architecture is typically composed of a presentation tier, a domain logic tier, and a data storage tier.
At the top of the diagram, we can see various application types. This is the presentation tier, and it is the responsibility of these applications to only perform the functions to gather and display information. If they are required to perform calculations, store or retrieve data then they must interact with another layer, the business logic layer.
The business logic is usually a separate assembly or web service which provides a common place for any logic to be performed. This includes calculations, data retrieval and data storage. If this tier requires to store or retrieve data then it, in turn, calls on the data access tier.
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 - 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 back to the business logic tier.
Using this architecture, the presentation tier is not concerned with how to retrieve data which means that upgrades or extensions to the presentation can be performed quickly. It also means that multiple applications (website, mobile applications, desktop applications, web services and so on) can use the same business logic and data access without duplication of code, resulting in consistent results across applications.
Another advantage of n-Tier Architecture is that separate teams can work on each tier once a common interface is agreed upon. This allows web developers to develop web applications, database application developers to develop data access, Windows Forms developers to develop applications and so on.