Development teams always need greater flexibility by allowing them to update a specific part of an application independently of the other parts. This added flexibility can improve overall time-to-market and decrease development cycle times by giving development teams the ability to replace or upgrade independent tiers without affecting the other parts of the system.
So, this feature always guides us to using a 3-tier architecture on our systems.

What is .NET 3-Tier Architecture?

Is one of the software architecture type that dividing the project into three layers:

  • User interface (Presentation) layer.
  • Business (Application) layer.
  • Data access (Database) layer.

 

3tier-1

 

Why to use 3-Tier Architecture in Projects?

We use 3-Tier architecture to manage large projects. 
Suppose you have created 1000 entity code and all your logic contained only in one layer. 
Now you have new changes required  from windows application, mobile or web application. so you have to code again for all 1000 entities or your database storage is changed. Again you have to change the database connection in the all 1000 entities.

writing such a large amount of code is:

 

  • Time and money-wasting 
  • Difficult to understand: If a new developer joins you for the same project then it becomes very difficult to make him/her understand about the code and project.
  • No proper templatization: It becomes very difficult to find any specific part or project code.
  • Security Threat: Our database server is not secured because database server code is directly written in the page level.

So, to provide maintenance, flexibility, clean and understandable code we may use 3-Tier Architecture.

 

3tier-2

 

What is a Layer?

A layer is a reusable portion of code that performs a specific function. 
In the .NET environment, a layer is usually set up as a project that represents this specific function. This specific layer oversees working with other layers to perform some it’s goals.


Presentation Layer (UI):

This is the top layer of architecture, it can also be called the user interface layer. Where we can design the interface. It can be a website or windows application or mobile application. 
This layer has access only to the business layer through API calls.
The main function of this layer is to translate tasks and results into something which the end user can understand.


3tier-3


Business logic layer (BLL) – Application:

Is the bridge layer that connects the database layer and presentation layer. and perform all the application logic. used to validate the input conditions and map the data before calling a method from the data layer.
so, it processes commands, makes logical decisions, and performs calculations.
This might be written in C#, Java, C++, Python, Ruby, etc.


Data Access Layer (DAL):

It is used to make a connection with the database server. In this layer we can write database queries or stored procedures for insert, update, delete or select operation from the database.
It comprises the database/data storage system and data access layer. Examples of such systems are MySQL, Oracle, PostgreSQL, Microsoft SQL Server, MongoDB, etc. Data is accessed by the application layer via API calls.


Advantages of 3-Tier Architecture:

 

  • Each layer always uses your separate codes, so it is easy to modify the codes.
  • It is more secure because the access to the database is protected. 
  • Reusable code (code once, use many times).
  • Different parts (Tiers) can be stored on different computers.
  • Different Platforms and Languages can be used
  • Migration to new graphical environments is faster
  • Posted data from the UI layer can be verified or validated at the business layer before updating it to the database.
  • Application layer/Business layer can be a protection shield to the database
  • Modularized:
    • You need only to change part of the code.
    • You can deploy only one part.
    • You can Test only one part.

Disadvantages of 3-Tier Architecture:

  • High installation cost.
  • It takes more time to build.

Add new comment

This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.