Re: dual controllers
Re: dual controllers
On Sun, Oct 13, 2002 at 11:33:56AM -0700, Keith Ray wrote:
>
One or more Smalltalk environments (VisualWorks), have the concept of
>
"ValueModel" objects, which can decouple a model from a view at very
>
low levels (for example, a one button "view" can be linked by an
>
ValueModel Adapter to a single boolean variable in your model.) There
>
seem to be docs at
>
<http://www.exept.de/exept_99/onlineDoc/english/programming/
>
vmodels.html>.
The above refers to ST/X but it's pretty close to VW usage. Also
coming from VisualWorks, one thing I do miss in Cocoa is the
separation of target/action from notifications. If I want one thing
to know a value changed, I can usually use the target/action paradigm;
if I want many things to know, I have to construct and use a
notification, which involves several steps and is rather painful.
Smalltalk has a very simple dependency mechanism - 'self changed:',
'self changed: with:', and 'update: with: from:' - which along with
the various adapters that the ValueModels use to wrap it, save a lot
of repetitive coding.
>
Because of Objective-C's relationship to Smalltalk, it theoretically
>
would be very easy to port this ValueModel concept to Cocoa (it might
>
require extending via subclasses or class categories all of the current
>
widget objects to add some of the necessary features). With
>
considerable difficulty, this concept has been ported to Java and
>
called "XMLTalk"
>
<http://www.trcinc.com/knowledge/software/xmltalk/xmltalk.asp>.
Yes, though it's unlikely to be practical without Interface Builder
support. I never, ever want to go back to programmatic interface
building, or even something (IMO) inferior like VW's UIBuilder and
fragile UISpecifications.
>
It is also an interesting "lack" that the book "Design Patterns" by
>
Gamma, et al., doesn't have the ModelViewController pattern as one of
>
its patterns... perhaps because of their rule that a pattern had to be
>
found in three independently-developed pieces of software to qualify
>
for inclusion in the book. The original Smalltalk "controller" is now
>
built into our operating systems -- the thing that listens for events
>
and routes them to the correct widgets -- so ValueModel may be more
>
helpful as a design pattern.
It's bizarre that many people mention MVC in the same breath as
Smalltalk and fail to mention that the Smalltalk Controller doesn't do
what everyone seems to think it does - in most systems such as Cocoa,
NSResponder subclasses (primarily views and cells) do most of the
things that a controller would in Smalltalk. The ApplicationModel is
probably closest to what you'd use a NSWindowController for in Cocoa.
--
=Nicholas Riley <email@hidden> | <
http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.