Re: Notifications vs. messaging
Re: Notifications vs. messaging
- Subject: Re: Notifications vs. messaging
- From: Georg Tuparev <email@hidden>
- Date: Mon, 1 Oct 2001 13:41:42 +0200
Well, last time I was looking at the source of Sketch was when it was
still called Draw ;-) but I think I can replay this one. It sends
notifications, because it is not known if the Palette is initialized at
the moment of the event. Of course one can send message to nil, but this
will get messy when the palette gets loaded for the first time. It has
to tell all open documents that it is now active, and in addition should
also listen for other documents getting opened. With other words, big
mess... It is a general design pattern, that if you have multi-document
application with helper View objects (e.g. Palettes, Inspectors, etc)
one should connect the Model, with all helper Views and Controllers
indirectly through notifications. I still remember the
pre-NSNotification days. Tones of lasagne code was written...
gt
On Monday, October 1, 2001, at 04:15 AM, Brian Hook wrote:
That seems like a good rule. However, Sketch sets up a notification
for when the tool palette changes. I'm curious why the sample code
doesn't just have messages being sent directly -- is it because they
don't know many documents might exist and thus registering all
documents with the tool palette would be ugly?
Georg Tuparev
Tuparev Technologies
Klipper 13
1186 VR Amstelveen
The Netherlands
Mobile: +31-6-55798196