[squeak-dev] Morphs and Data Question

Trygve Reenskaug trygver at ifi.uio.no
Mon Oct 26 09:26:52 UTC 2020


Hi Eric,
I believe using a step method is unnecessarily obscure and inefficient. 
I nearly always use the old ST80 /changed:/update:/ mechanism for MVC 
implementations:

 1. A View set up the mechanism by sending/model addDependent: self/.
    /Object>>addDependent//: anObject /is a predefined method.
 2. Whenever the Model changes, you send /model changed: aSymbo//l//.
    //Object>>//changed: aSymbo//l///is a predefined method.
 3. /Object>>changed:/ causes the object (Model) to send /update:
    aSymbol/ to all its dependents (Views)
 4. /You override Object>>update/: in your View to make it refresh itself.

Best
Trygve

On 2020-10-25 15:44, Eric Gade wrote:
> Hi all,
>
> I have a quick question that is perhaps very elementary. What is the 
> best way to design my Morph subclasses so that they "react" to changes 
> on their models? For example, if I have some data related model with 
> text that updates and I want the "view" (the Morph) to update whenever 
> this occurs? In my own quick code I've always just implemented a 
> `step` method that checks for data on the model updates, but is that 
> too brutal and inefficient?
>
> Thanks,
>
> -- 
> Eric
>

-- 

/The essence of object orientation is that objects collaborateto achieve 
a goal. /
Trygve Reenskaug mailto: trygver at ifi.uio.no <mailto:%20trygver at ifi.uio.no>
Morgedalsvn. 5A http://heim.ifi.uio.no/trygver/
N-0378 Oslo http://fullOO.info
Norway                     Tel: (+47) 468 58 625

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20201026/344e7557/attachment-0001.html>


More information about the Squeak-dev mailing list