neil@comp.lancs.ac.uk (Neil Haddley) (02/10/89)
The addition of 'Holder' to MVC
-------------------------------
Unfortunatley there is still a lack of useful reference material
in the public domain to guide smalltalk programmers in attempting
to create complex MVC type tools.
To correct this in part I feel that it would be useful if some
smalltalk 'experts' could provide some simple 'tips' here. In
this spirit (Although I would not claim to be an expert myself)
there follows some commonsense observations about the usefulness
of 'Holders' in creating complex MVC tools.
*WARNING* I am not attempting here to teach any grandmother to
suck eggs :-)
Simple MVC tools have no independent 'state'. Rather what is
displayed in the tool corresponds quite easily to what is in the
instance variables of the underlying Model (The Real Object being
Manipulated). More exactly what is displayed corresponds to what
can be got at via messages to the Model, but lets not split
hairs.
Complex MVC tools however do usually have some indepentent
'state', and a major problem is where this state can be put.
The view is a bad place, the Controller is a bad place, and the
Model is a very bad place.
The solution (used in the existing system code) is the creation
of a Holder Object. This object sits between the Model and the
View and Controllers.
-------------- Controller
<--- ^
Model |
. <--- V Fig1 Simple MVC Tools
. ------------- View
. ^
..............................
---- Controller
<-- ^
Model <--- Holder |
. <-- V Fig2 Complex MHVC Tools
. --- View
. ^
..................
Key:
---> Pointer (Instance Variable)
...> Dependency
There are slight problems in that the dependency is messed up,
and Controller Manipulation messages have to be redirected to the
Model, but it is not to difficult to get round these.
One could even introduce a new class Holder [or StandardSystem-
Holder :-)] to tidy things up ?
See the Form Editor is a simple holder example, here a Form-
Holder is used to hold a temp copy of the form being edited in
case 'cancel' is needed. Although other examples exist (String-
Holder etc).
Perhaps even the addition of a Holder is not enough, perhaps more
extra components are useful (but I hope not).
Finally I use MHVCs all the time
[and I've never had a single filling :-)].
Hope this is of interest to some.
Neil
--
EMAIL: neil@comp.lancs.ac.uk | Post: University of Lancaster,
UUCP: ...!mcvax!ukc!dcl-cs!neil | Department of Computing,
| Bailrigg, Lancaster, UK.