Tuesday, 4 September 2012

What's the difference between “Layers” and “Tiers”?

Layers are a logical separation and tiers are a physical separation


Layers are a means of logical separation, and are an architectural pattern to separate concerns. Logical layers help you organize your code better.

For example an application can have the following layers.

1)Presentation Layer or UI Layer
2)Business Layer or Business Logic Layer
3)Data Access Layer or Data Layer

When deploying an application, these layers might exist either on one machine, or on multiple machines.

  In no way is it implied that these layers might run on different computers or in different processes on a single computer or even in a single process on a single computer. All we are doing is discussing a way of organizing a code into a set of layers defined by specific function.
The above three layers reside in their own projects, may be 3 projects or even more. When we compile the projects we get the respective layer DLL. So we have 3 DLL's now.

Depending upon how we deploy our application, we may have 1 to 3 tiers. As we now have 3 DLL's, if we deploy all the DLL's on the same machine, then we have only 1 physical tier but 3 logical layers.

If we choose to deploy each DLL on a separate machine, then we have 3 tiers and 3 layers.


Physical tiers however, are only about where the code runs. Specifically, tiers are places where layers are deployed and where layers run. In other words, tiers are the physical deployment of layers.

Single Tier : Every thing was stored in a single system like  three layers( UI, BL, DAL) are in one system. Users need to access this centralized machine.

Two Tier  : Two tier means the user interface is in one system, and BL and DAL is in one system.

Three Tier : Three tier means three layers are in different, different systems

N-Tier :  means which is having many systems..like a banking project ,suppose a Debit card project, which deals with the many locations ,the card holder will swipe somewhere, the bank server is somewhere in the system 

No comments:

Post a Comment