Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

3-Tier Architecture in C# Web Application

0.00/5 (No votes)
27 Dec 2012 1  
Hello Everyone,This is my first article. Here I am giving you a brief intro about developing an application in 3-tier

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

Hello Everyone,

This is my first article. Here I am giving you a brief intro about developing an application in 3-tier architecture.

Architecture is the most important part of your application, the way you build your application decide the reliability and flexibility of it. The powerful structure of the application helps users as well as developers in an efficient way.

One of the most well known and frequently adapted structure is 3-Tier Architecture. Let’s have a look first what a 3-tier architecture is and how it works :

3-Tier Architecture Overview

There are three main layers in this architecture,

(1) Presentation Layer

This layer interacts with the user. What you see in the website is generally implemented in presentation layer. Web forms, UIs, Panels and that all come in this layer where user can be able to interact with the application.

(2) Business Layer

This layer contains the main logic of your application. Here all the classes, properties, constructors and methods are implemented. This layer gets the data from presentation layer and pass it to the data access layer to perform actions on database. Data Access layer hence, returns the value to the business layer and it again pass this value to the presentation layer. So business layer is the bridge between presentation and data access layers.

(3) Data Access Layer

This layer is only authorized(desirably) to make operations on database and perform CRUD (Create,Read,Update and Delete) queries on the database. It will run stored procedures and return data processed by them and pass it back to the business layer.

So, in standard 3-Tier architecture, Presentation Layer never communicate directly with Data Access Layer and vice-versa.

Conclusion:

Now, an obvious question in your mind would be “Why 3-tier architecture??” here is the answer,

3-tier application architecture provides a model for developers to create a flexible and reusable application. By Breaking up an application into different tiers, developers only have to modify or add a specific layer, rather than have to rewrite the entire application over. For example, if you want to add a new field “mobile” to the user table in database, you will have to change the code each and every place where you required to get this field, update this field or insert value into this field. But if you have implemented a 3-tier architecture, you can just add a new property to the user class and that’s it!!

Since the business logic is separated from the data access layer, changing the data access layer won’t affect the business logic much. Let’s say if we are moving from SQL Server data storage to Oracle there shouldn’t be any changes required in the business layer component and in the presentation layer. We would only make the changes to data access layer and that’s it, again!!

So, from the developer’s view, the application built using tired architecture is efficient and well manageable.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here