Understanding Layer architecture in C SHARP


Here in this article, I would like to cover the typical three layer architecture in C# .NET which is very useful approach for coding. It makes application more understandable, easy to maintain, easy to modify and help to maintain good look of architecture.


First let me give you a small overview about the topic I would like to cover in this article.

·         Three Tier/Layer Architecture Design Components

·         Demo: Three Layer Windows Application in C#.NET

3-Tier Architecture:

3-Tier architecture contains 3 layers:

1.    Application Layer or Presentation Layer 

2.    Business Access Layer (BAL) or Business Logic Layer (BLL

3.    Data Access Layer (DAL)


1.    Application Layer or Presentation Layer :

Presentation layer is the layer in which the users interact with an application. This layer contains UI part of our application i.e., our aspx pages or input is taken from the user. This layer mainly used for design purpose and get or set the data back and forth.

2.    Business Access Layer(BAL) or Business Logic Layer(BLL) :

Business layer is mainly working as the bridge between Data layer and Presentation layer. All the Data passes through the Business layer before passing to the presentation layer This layer contains our business logic, calculations related with the data like insert data, retrieve data and validating the data. 

3.    Data Access Layer(DAL):

Data layer contents Database Tables, XML Files and other means of storing Application Data. If we separate each layer by its functionality, then we come to know the below conclusion:

All above concept will be clear to see  my demo project which is given below:

Demo Project:
Presentation layer:
Picture of my presentation layer is given below:

In this project I saved student information . Here I used three TextBox to take input  i.e Student Name, Student ID and Email. After taking input click the Save Button to save this information in the database. Code behind the Save Button is given below:

Here I created two object aStudent and objManagerStudent for Student class and ManagerStudent class. Student class is a user defined type class where I defined student information. ManagerStudent is situated in BLL which is the bridge between Presentation layer and DAL. Picture of  class Student:

   We  know that this layer contain all type of  logic, , calculations related with the data like insert data, retrieve data and validating the data.

Hare I created an object named objGatewayStudent for class GatewayStudent which  is situated in DAL. Here I created a function to save the student information. With this function a link is built with the DAL by calling objGatewayStudent.Save(aStudent).Here some other logic also shown. This logic show the saving status (saved or failed).

DAL: All type of data connection goes here .

In this project  different classes are located in different folder according to their work. Here different folder are created for defining  job of  different  layer. This picture shows different layer of my project.

Leave a Reply

Your email address will not be published. Required fields are marked *