The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

MVC design: who's aware of what?

My main area of confusion with MVC is the controller/view integration.  Specifically, should view-level components be aware of the controller?  Or should that be handled by registering the controller as an observer?  They both seem equally feasible, but one ends up with circular dependencies.
John Cromartie Send private email
Friday, August 10, 2007
In the classic MVC:

Controller calls the view, and calls the model, and listens for events from both.

View calls the model to retrieve data and listens for events from the model.

Model knows about neither controller nor view.

The view doesn't need to know that the controller exists.
Chris Tavares Send private email
Monday, August 13, 2007
Check out Microsoft's Composite UI Application Block (CAB) which boast a very neat implementation of the MVC and MVP patterns.

CAB uses the Dependency Injection (DI) pattern to inject a Controller into the View that needs it.  No need for the Observer pattern.  If your not using .NET there are plenty of DI containers for Java that could perform the same trick.  I'm sure other languages also have DI containers or similar.

I'm working on a project that uses CAB which has almost enforced a well factored UI.  Has really helped keep the logic out of our WinForms.
sensible Send private email
Monday, August 13, 2007

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz