|
Ian Horrocks wrote...
Hi David,
I have read some very confusing stuff
on MVC myself. I didn't mention MVC in my book because I had read
too many conflicting things to be certain of what was right and
what was wrong. I am now confident I have got to the bottom of it
all. Separating the view and controller is very much a Smalltalk
thing. In Java, the Views and Controllers are combined. You may
have used the Observer interface and Observable class, if you
haven't then here is a quick overview ...
Suppose you had two different views
in your application - for example, a layout editor and a property
sheet in a development tool such as VB. Both these are Observers
and these are registered with an underlying model which extends
the Observable class. When the model is updated, it can be made to
call the update() method of the Observers that are registered with
it. The Observers can then decide how to react to the event. As
you can see, the view and controller are combined into an object
that implements the Observer interface and the model is the class
that extends the Observable class.
In the approach I have used in my
book, I have used controller objects to coordinate user interface
objects. This is in fact the Mediator pattern (Gamma et
al). So the controllers in my book could be more acurately
described as Mediators, rather than controllers.
Ian
|