Monday, January 19, 2009

n-Tier Architecture in ASP.NET




Architecture is an important feature and the very first step in the development of an application. n-Tier the term is used for multiple tier or multiple layers. n-Tier Architecture splits the solution process into different projects based on the business requirements. The main advantage of using n-Tier is that the complexity associated with the business and the process is reduced and it is easy to work with. The elements of performance, scalability and future development issues need to be considered when deciding on the architecture of the application depending on the priorities required.

The n-Tier application has three tiers or layers, they are called the presentation tier, the business tier and the data tier. Each layer interacts with the layer directly below, and has specific function to perform. Presentation Layer is responsible for displaying user interface to either programmer or end user. Programmer uses this layer for designing purpose and to get the data back and forth. In ASP.NET it includes ASPX pages, user controls, server controls and sometimes security related classes and objects.
The Business layer works as a mediator to transfer the data from presentation layer. In the three tier architecture the data access layer is not made to interact with the presentation layer. The architecture in ASP.NET includes using SqlClient or OleDb objects to retrieve, update and delete data from SQL Server or Access databases and passing the data retrieved to the presentation layer in a DataReader or DataSet object, or a custom collection object. The Data layer gets the data from the business layer and sends it to the database or vice versa. This layer is further divided into two sub layers Business Logic Layer (BLL) and Data Access Layer (DAL). DAL is responsible for accessing data and forwarding it to BLL. In ASP.NET it uses SqlClient or OleDb to retrieve the data and send it to BLL in the form of a DataSet or DataReader. BLL (Business Logic Layer) is responsible for preparing or processing the data retrieved and sends it to the presentation layer.
The Data layer gets the data from the business layer and sends it to the database or gets the data from the database and sends it to the business layer. In ASP .NET it is an SQL Server or Access database. It can also be Oracle, mySQL or even XML.
In an ASP.NET n-tiered architecture web pages do not make direct calls to the database. A given layer only communicates with its neighboring layers. ASP.NET Web pages should reference custom objects defined in the business object layer. These objects provide database information in a class structure.
The partitioning of ASP.NET applications into front-end, middle tier and back-end layers, the n-Tier architecture supports a more uniform, building block approach to application designs. Hardware and software for presentation, application and database functions can be scaled separately, and included more easily into complex e-Business environments.