A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.
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.
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.
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.
This topic is archived. No further replies will be accepted.Other recent topics
Powered by FogBugz