Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!gatech!swrinde!cs.utexas.edu!news.ti.com!ticipa!clw
From: clw@ticipa.pac.sc.ti.com (Chris Winemiller)
Subject: Re: Model View Controller
Message-ID: <1995Feb8.194400.11251@ticipa.pac.sc.ti.com>
Organization: None
References: <9501240837.AA00562@rt.el.utwente.nl> <macgremd-2601951458390001@ck43617516z.open.ac.uk> <vbykov.1.0041076C@cam.org>
Date: Wed, 8 Feb 1995 19:44:00 GMT
Lines: 86

In article <vbykov.1.0041076C@cam.org> vbykov@cam.org (Vassili Bykov) writes:
>In article <macgremd-2601951458390001@ck43617516z.open.ac.uk> macgremd@open.ac.uk writes:
>
>>Digitalk Smalltalk V Windows(ST/V) uses an "event-driven" framework which,
>>to quote Dan Shafer, "replaced an earlier design approach, known as
>>Model-Pane-Despatcher, or MPD,that many people found confusing and
>>confining."

<snip>

>> E.g., say a pane
>>obtains "Text" from the application when it opens (note it automatically
>>generates an event #opened);
>
>>aPane #opened perform: #obtainText:.
>
>>#obtainText is an event handler, a standard smalltalk method, which must
>>have exactly one paramater - the pane in which the event was generated.
>>The 
>>application must have a method
>
>>obtainText: aPane
>>   "code to respond to event #obtainText"

<snip>

>>If two panes have the same application as their owner, they can both use
>>"perform: #obtainText", therefore the "event-driven" framework can perform
>>the same function as MVC or MPD in a much simpler and convenient way. 
>
>Now comes the fun. Note that #obtainText: assumes a certain knowledge about 
>the pane passed to it as an argument, since it sends #setText: (or whatever) 
>to it.

I wanted to note that Digitalk's V/Win32 and Visual Smalltalk offerings
no longer force usage of panes as parameters, so the ensuing discussion
that I deleted is outdated so to speak. (Of course, one can still pass
panes as parameters if you desire.)  The old way of doing things in V
was as stated above. More correctly it would be:

    aViewManager addSubpane: aPane.
    aPane when: #opened perform: #obtainText:.

where the parameter to obtainText: was aPane, and #obtainText: was
always sent to the owner of aPane (i.e. aViewManager).

The equivalent way of doing this in V/Win32 or VisualSmalltalk is:

    aViewManager addSubpane: aPane.
    aPane when: #opened send: #obtainText to: aViewManager.

(The #when:perform: method is obsolete and doesn't even appear in the
virgin VisualSmalltalk image.) There is also the #when:send:to:with:
message as well. Note some significant differences from the old way:

1. The #obtainText message does not take a parameter (it must match the
   number of parameters the #opened event will pass, which is zero).
2. You can specify the receiver of the #obtainText message.
3. If an #opened: event passed a parameter, you can override this by
   using the #when:send:to:with: message.
4. (Not obvious): the event behavior is available to all objects, not
   just visual entities.  I have used this feature for some non-visual
   objects in a project I wrote.

>In MVC, on the contrary, the model knows *nothing* about the view(s) 
>displaying its value.

The preceding features (especially number 4) in V/Win32 and VST allow
you to create models that can generate events which can be "caught" by
other "model" objects or by "view" objects. Hence one can completely
disconnect models from all knowledge of views. I don't think this was
possible with prior releases of V.

BTW, it strikes me that with the advent of VisualWorks Parcplace has
moved closer to Digitalk's approach.  I haven't done much work with the
visual aspects of VisualWorks (I usually work in the "model" area of
things); but I believe VisualWorks applications are subclassed from
ApplicationModel, which seems to be sort of equivalent to Digitalk's
ViewManager.

Regards,
Chris
==============================================================
Chris Winemiller               Internet: clw@works.ti.com
Disclaimer: I do not speak for TI.
==============================================================
