Books MVC ASP.NET C# SQL Server WCF Written Test HR Round Subscribe C# Videos C# Programs Buy DVD

What is the difference between layers and tiers



Layers refer to logical seperation of code. Logical layers help you organise 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


The aboove 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 seperate machine, then we have 3 tiers and 3 layers.


So, Layers are a logical separation and Tiers are a physical separation. We can also say that, tiers are the physical deployment of layers.



Tiers:
1) Presenation Tier or UI Tier (Hosts the Presentation Layer or UI Layer). This can be considered as web server in case of an ASP.NET web application.
2) Application Tier or Business Tier (Hosts Business Layer or Business Logic Layer).
3) Data Access Tier or Data Tier (Hosts Data Access Layer or Data Layer).
4) Database Tier - SQL Server or Oracle (or any other database) which has tables, stored procedures and other database objects.


In general the following are the responsibilities of each layer or tier:


1)Presentation Layer or Tier is usually responsible for interacting with the user.
2)Business Layer or Tier is responsible for implementing the business logic of the application.
3)Data Access Layer or Tier is responsible for encapsulating the code that accesses the persistent data stores such as a relational database.

16 comments:

  1. Hello,
    Could you please let me know the difference between 3-tier architecture and MVP pattern
    Thanks,
    P

    ReplyDelete
  2. A MVC architecture is seperated into Model - Responsible the the management of the data, View - Responsible for displaying data in a meaningful way and the controller - that is responsible for the control flow of the application recieving input and interacting appropriatlly with the other layers.

    The most notable difference is that the view (that may be compared to the presentation layer when coupled with the controller) may speak directly to the model (the data).

    This would be a violation of an n-tier architecture. It is however possible to have a MVC architecture within a single tier of a 3-tier architecture. For example your presentation layer may be structured following an MVC architecture.

    ReplyDelete
  3. What are HTTP Modules and HTTP Handlers in ASP.NET?

    ReplyDelete
  4. Very Good article. The explanation is superb ! Keep them coming !

    ReplyDelete
    Replies
    1. Very Good article. The explanation is superb ! Keep them coming !

      Delete
  5. Hi can you please let me know how to deploy 3 different dll's into 3 diff. machines., and how does our app work under N Tier architecture..?

    ReplyDelete
    Replies
    1. In earlier technologies dll is different machines was accessed using DCom technologies. Now you can use WCF services to expose you class libraries(dll). Create a class library service and host it in console environment or in IIS and access that service in your presentation layer.

      Delete
  6. The explanation is awesome! Keep them coming dude!

    ReplyDelete
  7. This is a an amazing piece of explanation..... i m just so thankfull to u.

    ReplyDelete
  8. Very Good explanation.. thanks keep update us.

    ReplyDelete
  9. Can u please tell me wha t are table variables?

    ReplyDelete
    Replies
    1. Hi Krish, I have recorded a video and uploaded on youtube, that explains Derived tables, common table expressions, Views, Table Variable, Local and Global Temp Tables. Please watch Part 48 from SQL Server tutorial for beginners. I have included the link below.
      SQL Server, ASP.NET and C# Video Tutorials

      Delete
  10. What is web application and web site ? Difference ?

    what is 3 Tier Arch. and N Tier Arch. ? Difference ?

    Reply me on my mail id
    rajkumar.asp.net@gmail.com

    Thanks

    ReplyDelete
  11. I found the articles in this site very useful, thanks for sharing the knowledge --Rohini

    ReplyDelete
  12. Create a MVC3 app like website with basic CRUD and movie listing. We would like to have the following entities in the application.

    Entities
     Actors
    - Name
    - Sex
    - DOB
    - Bio
     Movies
    - Name
    - Year of release
    - Plot
    - Poster (image)
     Producers
    - Name
    - Sex
    - DOB
    - Bio


    Relationships
    ● Actor can act in multiple movies
    ● Movie can have multiple actors
    ● Movie has only one producer
    ● Producer can produce multiple movies


    Application specifics
    1. Screen to list all movies
    2. Screen to ‘add’ a new movie with the necessary form elements and at the same time to allow to add ‘Actors’ and ‘Producers’ to the movie. (We want to see how you accomplish this task).
    3. ‘Listing’ screen should allow user to click on a movie and view all the details of the movie.
    4. ‘Listing’ screen should allow user to click on ‘Edit’ and edit all the details of the movie and save it.
    5. ‘Listing’ screen should allow user to click on ‘Delete’; pop-up a confirm message (Yes/No) for the user and if the user clicks ‘Yes’ delete the movie from the Db.
    6. Adding / Editing / Deleting a movie should take the user back to the ‘Listing’ screen with a notification message.


    can u solve this and mail me: nknitin579@gmail.com

    ReplyDelete

If you are aware of any other asp.net questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us