Click here to Skip to main content
15,881,898 members
Articles / General Programming / Architecture

3-Tier Architecture in C# Web Application

Rate me:
Please Sign up or sign in to vote.
2.60/5 (3 votes)
27 Dec 2012CPOL2 min read 30K   6   2
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.

The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
This is a Collaborative Group

754 members

Comments and Discussions

 
GeneralMy vote of 1 Pin
Ahmer Bashir26-Jan-15 17:29
professionalAhmer Bashir26-Jan-15 17:29 
GeneralMy vote of 3 Pin
khurram ali lashari3-Mar-14 15:19
professionalkhurram ali lashari3-Mar-14 15:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.