Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!news.kei.com!wang!news
From: zviki@tx.technion.ac.il (Cohen Zviki)
Subject: Re: [ALL] Does anyone use dependencies?
Organization: Technion, Israel Institute of Technology
Date: Tue, 2 Jan 1996 22:11:35 GMT
Message-ID: <DKKqzC.BoB@discus.technion.ac.il>
References: <4c7026$u5u@watnews1.watson.ibm.com>
Sender: news@wang.com
Lines: 44

	Hello !

David N. Smith (dnsmith@watson.ibm.com) wrote:
: A question for discussion:

:    What good are dependencies?
:    
: Please ignore any use that might occur hidden away in system classes. I'm
: interested in how dependencies are used in real applications, if they are
: used at all.

	Although IBM Smalltalk does not do any big use of them, VisualWorks
does. VisualWorks application building classes are built around the MVC
(aka Model View Control) concept, where the model does not have to know a thing
about his view/s. So, how does the view/s change when the model changes ? One 
way is to make the model aware of his view/s (like keep a view list) and send
each of them (if there are any) an appropriate message (assuming they can
respond it - which means each view must implement all known messages).

	The cleaner way is to send yourself a #changed message with the right
parameters. That way, the change message is propageted to all the dependents.
It does not matter how many dependents you've got... Also, if you're a 
dependent you can ignore some of the change messages. BTW, here's there's a 
catch, since your #update: message will look like an ugly C switch...

	One of the most basic things in VW is the ValueHolder. It's a really 
cool class - you can set and get its' value with #set: and #get, and by 
adding yourself as a dependent of that ValueHolder you will be notified 
whenever the value is changed. This is very useful in case you want to 
do some checking or conversion of the value set in a variable (for that VW
came up with the Pluggable Adaptors...).



------------------------------------------------------------------------------
Zviki Cohen

In-line Skater                      Computer Science student 
Macintosh Developer                 Technion - Israel Institute of Technology
Smalltalk Hacker
		  E-mail:  zviki@tx.technion.ac.il
		  Homepage: http://wstud.cs.technion.ac.il/~s2533197/

    	"It's easier to attract honey with flies"
