What is MVC by Martin Fowler

本文深入探讨了MVC架构的分离原则,解释了模型、视图和控制器的角色及其交互方式,强调了观察者同步机制的重要性,以实现高效的数据同步与用户界面更新。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值