What is MVC by Martin Fowler

http://martinfowler.com/eaaDev/uiArchs.html

    没太看懂,一些看懂的片段:

 

         So now I think it's time for some soundbites on MVC.

  • Make a strong separation between presentation (view & controller) and domain (model) -Separated Presentation.
  • Divide GUI widgets into a controller (for reacting to user stimulus) and view (for displaying the state of the model). Controller and view should (mostly) not communicate directly but through the model.
  • Have views (and controllers) observe the model to allow multiple widgets to update without needed to communicate directly - Observer Synchronization.

 

http://stackoverflow.com/questions/26685/what-is-mvc-and-what-are-the-advantages-of-it

 

http://stackoverflow.com/questions/5863870/how-should-a-model-be-structured-in-mvc/5864000#5864000

 

 

http://www.codinghorror.com/blog/2008/05/understanding-model-view-controller.html

 

  1. Models

    Models represent knowledge. A model could be a single object (rather uninteresting), or it could be some structure of objects.

    There should be a one-to-one correspondence between the model and its parts on the one hand, and the represented world as perceived by the owner of the model on the other hand.

     

  2. Views

    A view is a (visual) representation of its model. It would ordinarily highlight certain attributes of the model and suppress others. It is thus acting as a presentation filter.

    A view is attached to its model (or model part) and gets the data necessary for the presentation from the model by asking questions. It may also update the model by sending appropriate messages. All these questions and messages have to be in the terminology of the model, the view will therefore have to know the semantics of the attributes of the model it represents.

     

  3. Controllers

    A controller is the link between a user and the system. It provides the user with input by arranging for relevant views to present themselves in appropriate places on the screen. It provides means for user output by presenting the user with menus or other means of giving commands and data. The controller receives such user output, translates it into the appropriate messages and pass these messages on to one or more of the views.

你可能感兴趣的:(设计模式,mvc)