Saturday, October 21, 2006

Understanding 3-Tier vs. 3-Layer Architecture

The terms tier and layer are frequently used interchangeably, but actually there is a difference between them: Tiers indicate a physical separation of components, which may mean different assemblies such as DLL, EXE etc on the same server or multiple servers; but layers refers to a logical separation of components, such as having distinct namespaces and classes for the Database Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL). Therefore, tier is about physical separation and units of deployment, and layers are about logical separation and units of design.

Creating a multi tier project design is more suitable and advisable to mid to large-size projects, whereas a good multi-layered design is suitable for small to mid-size projects.

Let’s understand this difference more closely with my earlier posts on “Developing 3 Tier Application in .NET 2.0”. In reality this example is 3-layer architecture because all the layers are logically separated but stay in one code. Following are the namespaces of each layer

1. Vishwa.Example.Data
2. Vishwa.Example.Business
3. Vishwa.Example.WebSite1


The final DLL contains all the above layers: Vishwa.Example.WebSite1

Now, let’s think how to build the same project in true 3-tier architecture. For simple understanding, each layer will be moved to a separate project and thus creating following three dlls. These dlls can stay on the same machine or different servers.

1. Vishwa.Example.Data.dll     --- see  Data Transfer Objects (DTO) - Data Access Layer
2. Vishwa.Example.Business.dll --- see Data Transfer Objects (DTO) - Business Layer
3. Vishwa.Example.WebSite1.dll  -- Now you can refer the above new dlls to perform the same operation


But, by just moving the code of each layer into a separate project will not work, because first and foremost issue is: each layer depends on other layer, so you can not compile one project without other one and here you are in catch 22 situation.

So you will require changes into current design. Also, if you are not planning to keep all the layers in the same folder of your application, then another big issue- how to refer and communicate with each layer’s object. Here is some approach you can take for each layer to convert into a tier model.

  • Literally, create a separate project for each layer.
  • For Database Access Layer and Business Logic Layer ASP.NET Web Services or .NET Remoting can be used. If you can use .NET 3.0 Windows Communication Foundation (WCF) Services, that will be great, they seem to me like Web Services but more powerful, secure and flexible than Web Services.
  • User Interface Layer will stay as ASP.NET Web Site but some changes will be required for invoking or calling Business Objects. However, existing BLL and DAL layers will be removed from current project.
  • Additionally, I will recommend using Microsoft Enterprise Library - Application Blocks for .NET 2.0. This library can help you to build a robust application, it provides solutions to common development challenges such as data access, logging and user interface etc. You can find more information at http://msdn.microsoft.com/practices
  • By using (Web) Services, you will move one step towards Service Oriented Architecture (SOA), which is becoming more popular now in enterprise application development.
You must be wondering why did I use the word 3-Tier instead of 3-layer?

First of all most of the time people are searching on key words like 3-Tier rather 3-Layer. Word 3-tier architecture is most frequently used but heavily misused in IT industry. So it is easier to bring people to the information they are looking for and then educate them as what exactly it means.

Needless to say that it was easier for me to take a simple example for 3- layer architecture design and explain each layer step by step. Developing a true multi tier approach may look like over killing of the sample project. I may write one sometime in future:).

41 comments:

radcorpindia said...

3 separate projects of class Library, for same application, It doesn't mean, that it is a 3-Tier / n-Tier Application.

It is the concern about whether is it a In process communication / out of process communication, in the case of (2-Tier, 3-Tier / n-Tier [Where n>=3]) Tire application.

If in process (should in the case of DLL --> In Process [ Out of process--> Database Service / DCOM / EXE, the application run on separate process space, withing a same machine or different machine]

Better you say "it’s a highly per formant n-Layered application, with multiple n -Tier options".

Anonymous said...

Thanks u r information

Unknown said...

Thanku for your information

Hai Trieu said...

thank you very much

Bishnu said...

great one

Anonymous said...

thanks ............

Anonymous said...

What i sthe difference between Tier and Layer in terms of Software project? Also how can we prevent the misuse of DLL use for data access or having business logic?

Windows Phone Application Development said...

Thanks for the nice information. I am sure, I will tweet this to my twitter account. This will help a lot of users.

Rajesh said...

Great blog on differentiate between 3-Tier and 3-Layer which quit confusing and mostly famous question asked by interviewer.
Thanks you very much ......

Anonymous said...

RADCORPINDIA guy is stupid..

Unknown said...

Thanks for your information.. :-)

web developers said...

Nice blog !
I like this !

Anonymous said...

thanx for d info..can u like ut a piksho of the 3tier architecture..tnx

ASHOK said...

Thanks....

ASHOK said...

Thanks....

virender said...
This comment has been removed by the author.
virender said...
This comment has been removed by the author.
virender said...

N-Layer means logical separation between code, and N-Tier means physical separation .

N-tier not good for small project due to communication between tier decrease performance of project.

n-tier better for large-mid project.

Hotel in Ranchi said...

After study a couple of of the blog posts in your website now, and I truly like your manner of blogging. I bookmarked it to my bookmark website listing and shall be checking again soon. Pls check out my website as properly and let me know what you think.
Best Hotel in Ranchi Budget hotels in Ranchi Cheap Hotel Rooms in Ranchi Economy hotels in Ranchi Luxury Hotels in Ranchi Restaurant in Ranchi Bar in Ranchi Best Banquet in Ranchi

software company in ranchi said...

You have described it very well. Now a day, I feel that, No need to go to out because Internet showing me a more information to read. Today I have got a new information from your blog.
Web design company ranchi Mobile Application Development E-commerce Website Development Custom Software Development Software Development Company Ranchi

Stacey said...
This comment has been removed by the author.
AimBin said...

I have read this article ..... a good one... but i have also found some interesting material at
http://freefeast.info/general-it-articles/3-tier-vs-3-layer-architecture-difference-between-3-layer-and-3-tier-architecture/
regarding 3-tier-vs-3-layer-architecture ....
Thought you people might like it...

SITL said...

Thanks for the information

SEO Company India
Link Building Packages
SEO Services Ranchi
Search Engine Optimization Services
Seach Engine Marketing Services
Affordable SEO Packages

Anonymous said...

Nice info about the differences.

For more information about Zodiac Signs.
http://www.zodiac-signs.in

Unknown said...

Hi,It’s unbelievable how much better Web Design Cochin will become when you take into consideration these four basic principles. There are always more things to consider, but a foundation of contrast, repetition, alignment and proximity will improve your designs dramatically.Thanks...........

Unknown said...

You have provided very useful information to we people. This info is useful in many ways.
Thanks for your hard work.
Website Development Company in Lucknow

Muksh Mishra said...

Thank you admin for such an informative blog. The businessmen know that they can make their business more develop with the help of IT services.

Website Development Company in Dehradun

Zeiko Technologies said...

Nice Post..........

Digital Marketing Service in Udaipur
SEO Service in Udaipur
Email Marketing Service in Udaipur
Social Media Marketing Service in Udaipur
Content Marketing Service in Udaipur
PPC Service in Udaipur
Online Marketing Service in Udaipur

Anonymous said...

very informative article thanks for the suggestion. Great post
SEO Expert In Udaipur

dhanlaxmi web said...

Thanks for helpful article!
http://dhanlaxmiweb.com/

Anonymous said...

web development company in rajasthan
Thanks for helpful

Actor Gautami said...

Very Nice!! Thanks for Sharing..

Peyari said...

Great Post!! Thanks for Sharing with us..

Peyari said...

Great Post!! Thanks for Sharing with us..

Web Design Company said...

Very Useful Information, Thanks for Sharing with Us.

Web Design Company said...

Very Useful Information, Thanks for Sharing with Us.

Instacart clone app development services said...

Amazing blog. I have never seen a blog like this. I have learned many thing from this blog. If you need any kind of mobile application development services then we offer best on demand app demand app development services.

Midinnings said...

Amazing COntent. Loved your blog.

Midinnings - Digital marketing Company in Udaipur

Rajveer singh said...

Very Good information for WordPress theme editing. It’s really helpful for our development team and me also. thanks for sharing this very useful information.
WordPress Web Design Company Udaipur

daisoftware said...


This article is worth sharing, so inspiring and full of information. Thankyou for sharing this!!
meal kit subscription service

worldfashiontips said...

World Fashion Tips - Best Beauty Fashion and Style Tips Blog

All, Apps, Automobile, Automotive, Beauty Tips, Blog, Business, Celebrity, Digital Marketing, Education, Entertainment, Fashion, Finance, Food, Games, Health, Home Improvement, Lifestyle, News, Real Estate, Social Media Marketing, Software, Sports, Technology, Travel, Website.