开发者

Which MVC flavor is more widely accepted?

I notice 2 distinct "flavors" of MVC:

1) "Original" MVC where the Model talks directly to the View 2) "Apple Cocoa" MVC where the Controller uses the Mediator pattern and Model and View never communicate directly

From link text:

The goal of MVC is, by decoupling models and views, to reduce the complexity in architectural design and to increase flexibility and maintainability of code.

That makes great sense to me. However with #1, as shown on wikipedia, you have a link between Model and View and therefore they seem quite coupled to me. It seems like "original" MVC does not solve it's goal.

In contrast, #2 to me very clearly results in a generic View that only knows how to display and input data via UI, a Model that does not care at all about how it is represented, and a Controller that knows about both and becomes the only potentially un-reu开发者_StackOverflow中文版sable code. It achieves the MVC goal.

This is good for me because I'm working in Cocoa which "Believes in" #2, and I'm working in plain C++ which I can make believe in anything. But which of these MVC flavors will I find out in the wild more? For instance, Ruby on Rails, Struts, PureMVC.. these "use MVC" but would I expect to see #1 or #2 there?

EDIT: Sounds like #2 is the more accepted one, so does any modern approach use #1, if so then what?


I'm not sure what's more universally accepted, but most people see Rails as being pretty much the 'spec' for MVC, and in Rails the model and view never (almost never) talk directly. The controller does all the finding and sending of model data to the view.


In asp.net Mvc the #2 approach is taken: the controller reads and writes from/to the model, sends and receives data to/from the views. Views and models never talk directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜