An MVC Question
I have a couple questions about MVC's.
First of all, if you have multiple controllers, should your model have static fields and methods? Or should you be more "OOP" and go through the tenuous work of passing a model object via constructors?
Secondly, lets say I have a controller that acts based upon some sort of listener. This listener listens for actions on a view. This means that the view has to do an addActionListener(some Controller). Thus, the view instantiates the controller... and I thought that the diagram of an MVC was that the controllers instantiate and talk to the model, and the model does the same for the views. Is it wrong to have the views talk to the controllers like this?
Thanks in advance
[742 byte] By [
dynobirda] at [2007-10-2 3:27:50]

> Secondly, lets say I have a controller that acts based upon some sort
> of listener. This listener listens for actions on a view. This means that
> the view has to do an addActionListener(some Controller).
> Thus, the view instantiates the controller...
Nope, it's the other way around: the view doesn't care less who or what
listens to, say, a button press. I always visualise the MVC pattern as
three separate boxes with wires hanging out from them. All three of them
have outlets too. It's the task of the application to hook up everything
right.
I take my designs a bit further: a model talks to a controller and vice versa.
A controller talks to a view and vice versa, but never does a view talk to
a model directly. I like it that way, even if the controller has to act as a
'Mediator' or a 'Proxy' for the model in this scenario.
Of course the 'controller box' consists of one or more little controller
classes, as do the view and/or model. But the 'Facade' pattern takes
care of that.
kind regards,
Jos
JosAHa at 2007-7-15 22:37:32 >
