Where can I find a dead-simple explanation of MVC?

前端 未结 12 1904
迷失自我
迷失自我 2020-12-23 15:07

At my company we\'re about to build a new site using ASP.NET MVC. My boss (marketing guy) would like to know some more about the technology so I\'ve tried to find a really g

12条回答
  •  天命终不由人
    2020-12-23 15:37

    M-V-C Think of it as: "Order Details (including Customer & Employee info)", "HTML/ASP Form (to display the OrderDetails)" and "Order details service class (having methods to SaveOrderDetails, GetOrderDetails etc.).

    The Model (Data Class e.g. OrderDetails)

    1. The data you want to Display

    The Controller (Service class)

    1. Knows about the Model (Order Details)
    2. Has methods to manage the Model
    3. And as such can be unit tested Its Single Responsibility is to manage the OrderDetails CRUD operations.
    4. It knows NOTHING about the View

    The View (ASP Page)

    1. Displays the Model (OrderDetail's ViewData).
    2. It has to know about the Model's structure so it can correctly display the data to the users on screen.
    3. The View's structure (style, layout, HTML etc., locale) can be changed at anytime without it changing anything in the application's functionality.
    4. And as such, many Views can display the same Model in many different ways.
    5. In multi-tenant web applications, Customer specific Views can be stored in a database table and displayed based on Customer information

提交回复
热议问题