The Model-View-Controller Design Pattern
说得非常好~
As a concept, the MVC design pattern is really simple to understand:
- The model(M) is a model or representation of your data. It’s not the actual data, but an interface to the data. The model allows you to pull data from your database without knowing the intricacies of the underlying database. The model usually also provides an abstraction layer with your database, so that you can use the same model with multiple databases.
- The view(V) is what you see. It’s the presentation layer for your model. On your computer,
the view is what you see in the browser for a Web app, or the UI for a desktop app. The view also provides an interface to collect user input. - The controller(C) controls the flow of information between the model and the view. It uses programmed logic to decide what information is pulled from the database via the model and what information is passed to the view. It also gets information from the user via the view and implements business logic: either by changing the view, or modifying data through the model, or both.