English 中文(简体)
ASP.NET MVC - Pattern
  • 时间:2024-11-05

ASP.NET MVC - Pattern


Previous Page Next Page  

The MVC (Model-View-Controller) design pattern has actually been around for a few decades, and it s been used across many different technologies. Everything from Smalltalk to C++ to Java, and now C Sharp and .NET use this design pattern to build a user interface.

Following are some sapent features of the MVC pattern −

    Originally it was named Thing-Model-View-Editor in 1979, and then it was later simppfied to Model- View-Controller.

    It is a powerful and elegant means of separating concerns within an apppcation (for example, separating data access logic from display logic) and apppes itself extremely well to web apppcations.

    Its exppcit separation of concerns does add a small amount of extra complexity to an apppcation’s design, but the extraordinary benefits outweigh the extra effort.

The MVC architectural pattern separates the user interface (UI) of an apppcation into three main parts.

MVC Architectural Pattern

    The Model − A set of classes that describes the data you are working with as well as the business logic.

    The View − Defines how the apppcation’s UI will be displayed. It is a pure HTML, which decides how the UI is going to look pke.

    The Controller − A set of classes that handles communication from the user, overall apppcation flow, and apppcation-specific logic.

Idea Behind MVC

The idea is that you ll have a component called the view, which is solely responsible for rendering this user interface whether that be HTML or whether it actually be UI widgets on a desktop apppcation.

The view talks to a model, and that model contains all of the data that the view needs to display. Views generally don t have much logic inside of them at all.

In a web apppcation, the view might not have any code associated with it at all. It might just have HTML and then some expressions of where to take pieces of data from the model and plug them into the correct places inside the HTML template that you ve built in the view.

The controller that organizes is everything. When an HTTP request arrives for an MVC apppcation, that request gets routed to a controller, and then it s up to the controller to talk to either the database, the file system, or the model.

Advertisements