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:).

40 comments:

  1. Thanks u r information

    ReplyDelete
  2. Thanku for your information

    ReplyDelete
  3. thank you very much

    ReplyDelete
  4. thanks ............

    ReplyDelete
  5. 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?

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

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

    ReplyDelete
  8. RADCORPINDIA guy is stupid..

    ReplyDelete
  9. Thanks for your information.. :-)

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

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. 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.

    ReplyDelete
  14. 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

    ReplyDelete
  15. 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

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. 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...

    ReplyDelete
  18. Nice info about the differences.

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

    ReplyDelete
  19. 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...........

    ReplyDelete
  20. 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

    ReplyDelete
  21. 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

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

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

    ReplyDelete
  24. Very Nice!! Thanks for Sharing..

    ReplyDelete
  25. Great Post!! Thanks for Sharing with us..

    ReplyDelete
  26. Great Post!! Thanks for Sharing with us..

    ReplyDelete
  27. Very Useful Information, Thanks for Sharing with Us.

    ReplyDelete
  28. Very Useful Information, Thanks for Sharing with Us.

    ReplyDelete
  29. 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.

    ReplyDelete
  30. 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

    ReplyDelete

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

    ReplyDelete
  32. 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.

    ReplyDelete