[newbie]Does Model + Morphic = MVC?
Ned Konz
ned at bike-nomad.com
Fri Feb 22 04:19:24 UTC 2002
On Thursday 21 February 2002 07:52 pm, Andre Maloney wrote:
> Looking in the image, I see that the browsers are subclassed off Model
> which makes sense in light of his rule.
>
> I don't fully understand it, but it appears that using the dependency
> mechanism in Model is more efficient than the one in Object.
> (I'll let that simmer for a while.)
The only difference between Model and Object is that each Model has its own
dependents collection, rather than using a global Dictionary. And EventModel
instances likewise have their own dependents dictionaries. But both protocols
will work with any Object, since there are globals to hold these dependencies
as well.
So (for instance) you can use the usual MVC protocols with any object (even
non-Model ones); if your object that has dependents does not override
#myDependents (which Model overrides), you'll get an entry in the global
(Object class variable) DependentsFields. Likewise for EventsFields and
#myEvents. And the only overhead from not using Model or EventModel is an
extra lookup in these dictionaries.
There are at least two publish/subscribe frameworks in Squeak: the
changed/update:/Model ("updating" category) one from classic MVC, and the
when:sendTo:/trigger:/EventModel ("events" category) one, which is faster
(because it has less overhead). The Pluggable* components use the old one
(that is, Model).
Morphic is, in general, agnostic with respect to notification. Some Morphic
classes use the classic MVC notification (notably the Pluggable* ones, for
compatibility with the MVC GUI). Most poll in their step methods rather than
get notified. Some do both.
But it's certainly not required to have a separate Model for each Morph (in
fact, that's probably the exception, other than for the more old-fashioned
(classic?) UI elements like browsers). Many Morphs are their own model.
Since Morphs don't require notification in order to change themselves (they
can poll instead if they want, using #step), there's more flexibility in
Morphic UI design: you can use notification, or not.
--
Ned Konz
currently: Stanwood, WA
email: ned at bike-nomad.com
homepage: http://bike-nomad.com
More information about the Squeak-dev
mailing list
|