locked
Differences between MVC and 3-Layer? RRS feed

  • Question

  • User1356013393 posted

    In my opinion, these architectures have some differences, such as:


    1. 3-layer is a linear architecture, but MVC is a triangle architecture.
    2. Presentation Layer of 3-layer includes View and Controller of MVC??? And Model of MVC includes Business Layer and Data Access Layer of 3-layer


    Please help me, I think 2 diffrences above are not obvious or are incorrect!

    Tuesday, May 11, 2010 11:09 AM

Answers

  • User541108374 posted

    Hi,

    MVC itself is a design pattern which is used in an architecture, a multilayered in your case.

    I still cannot understand that how Model component lives in UI layer.

    You see the Model as your domain model but that's not the case. In the Model you should have your ViewModels, custom classes which are mostly flattened out representations of your domain model, only to be used in the presentation layer. Tools like Automapper can help you in that.

    I suggest that you read the book ASP.NET MVC in Action of which soon version 2 comes out to get a good understanding of ASP.NET MVC and where it fits in. It seems the new book by Dino Esposito: Programming Microsoft ASP.NET MVC (which was released in May 2010 and covers MVC 2) is a decent one.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 11, 2010 12:13 PM

All replies

  • User541108374 posted

    Hi,

    MVC is just one layer, the presentation or UI layer in your architecture. What you typically should put in your Models folder are the ViewModel classes, not your domain classes. In the other layers you specify your business and persistence logic and you can even put a service layer in between if you need. Just one thing to remember is that the MVC design pattern lives in one layer.

    Grz, Kris.

    Tuesday, May 11, 2010 11:14 AM
  • User1356013393 posted

    Hello Kris!

    First things first, thank you for helping me!

    You meant "MVC is a design pattern", it is not a architecture? Is it right?

    I still cannot understand that how Model component lives in UI layer.


    For example, I have:

    Data Access Layer: Class Database (connect, disconnect, query, nonQuery, etc.)

    Bussiness Layer: Class User  (function: add, delete, edit, etc.)

    View Layer: display a list of user with delete, edit buttons.


    When I click the Delete Button (for an user) -> Controller componet is called.

    Model is calling Delete Function in Class User and responses result to Controller.

    Controller generate View.


    Those are what I'm thinking. Hope they are right Frown

    Tuesday, May 11, 2010 11:57 AM
  • User541108374 posted

    Hi,

    MVC itself is a design pattern which is used in an architecture, a multilayered in your case.

    I still cannot understand that how Model component lives in UI layer.

    You see the Model as your domain model but that's not the case. In the Model you should have your ViewModels, custom classes which are mostly flattened out representations of your domain model, only to be used in the presentation layer. Tools like Automapper can help you in that.

    I suggest that you read the book ASP.NET MVC in Action of which soon version 2 comes out to get a good understanding of ASP.NET MVC and where it fits in. It seems the new book by Dino Esposito: Programming Microsoft ASP.NET MVC (which was released in May 2010 and covers MVC 2) is a decent one.

    Grz, Kris.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 11, 2010 12:13 PM