[NEWBIE] Question on dependencies in Squeak

swan swan at hayman.cs.umass.edu
Sat Oct 9 14:43:07 UTC 1999


Hi. I'm a newbie to Squeak and Smalltalk. I've been reading several intro
books on Smalltalk, of which the best is "The Art and Science of
Smalltalk" by Simon Lewis (one of the books recommended by Todd Blanchard
on an IWE forum. Thanks Todd!). Lewis' Chapter 8 is on the dependency
mechanism of Smalltalk (VW dialect) and is quite well written, covering
changed, changed:, changed:with: and update:, update:with:,
update:with:from. He also discusses blocks and the perform: method. Lewis'
book is well written and very clear, and I grok the dependency mechanism
in ST-80 (VW).

However, Squeak doesn't employ the same mechanism. Blocks still work the
same. changed, and changed: are still there, but changed:with: is gone and
update is there, but the others are gone. Further, in Morphic, they've
been overwritten, so changed/update deal with screen redraws/refreshes
instead of object dependencies.

I've been through several pieces of Morphic sample code (specifically, the
Counter example of Tim Olson and the Rolodex example of Bob Arning.
Thanks!!) None of these have a mechanism like dependency in them. In Tim's
code, the mechanism is to specify a target (Object) and an ActionSelector
(method) for each widget. Then, when the widgets are set up, he modifies
the model so it is aware of all the views/Morphics. In Bob's code, there
are readSelector and writeSelector vars which specify methods for
getting/setting data in the model, but I don't see any general update
mechanism whereby the model can notify all objects that depend on its
values that it has changed.


model: is defined in several Morphic classes, and allows a Morphic to
specify which model needs to know of its activities. However, checking
several examples (for example, evaluating 

(PlayWithMe1 allInstances at:1) dependents 

in PlayWithMe1 returns () showing that the dependency model is not used
there, but slots and slotName seem to be.) MorphicModel has model: thang
slotName: nameOfThisPart. Poking around in the Morphic classes I keep
seeing the method

wantsSlot
	"For now do it the old way, until we sort this out"
	^ true

which makes it look like slots are a method of doing dependencies that is
going away.

MorphicModel>>use: orMakeModelSelectorFor: in: is not the easiest method
to understand, and is definite overkill for a lot of what I want to do.

So, how do I do dependencies in a Morphic framework? I've heard that
Morphic can be viewed as a combination View/Controller. How do I set it up
that my UI elements don't know about each other, and know very little
about the model (access methods only), and the model can tell morphics to
update but doesn't know anything about how many there are, how they work,
and what they are like?

Any pointers or references would be greatly appreciated.

TIA
-Russell Swan





More information about the Squeak-dev mailing list