[squeak-dev] An old gripe (or: SystemChangeNotifier +
Announcements = Sanity?)
Norbert Hartl
norbert at hartl.name
Fri Mar 6 10:35:37 UTC 2009
On Thu, 2009-03-05 at 21:32 -0800, Andreas Raab wrote:
> Folks -
>
> While doing some preferences stuff I ran into one of my "most-hated"
> issues in Squeak. Anyone who has ever encountered SystemChangeNotifier
> must have noticed how terrible it is to use it. I mean, just look at
> this code:
>
> prefEvent: anEvent
> "Check if this system event defines or removes a preference."
> (anEvent itemKind = SystemChangeNotifier classKind and: [anEvent
> isRemoved]) ifTrue:[...].
> anEvent itemKind = SystemChangeNotifier methodKind ifTrue:[
> (anEvent isRemoved or:[anEvent isModified]) ifTrue:[...]
> (anEvent isAdded or:[anEvent isModified]) ifTrue:[...]
> ].
>
> just needless, pointless lines of case statements. How do people feel
> about replacing that mess with Announcements? If you really want to have
> all events you register for SystemEvent and if you'd like to be more
> specific you go for more specifically for ClassEvent or even more
> specifically for ClassAddedEvent. It would also remove the need for all
> of these weird tests like
>
> anEvent itemKind = SystemChangeNotifier methodKind and:[anEvent isRemoved]
>
> and just replace them with something like "anEvent isMethodRemoval". It
> would likely be faster too, since most places aren't really interested
> in *all* events either.
>
> It would mean that Announcents would have to go core but this cleanup
> alone seems worth it. I also suspect that adding Announcements and
> fixing SystemChangeNotifier may remove more code than it would add.
>
> How do people feel about that?
>
It sounds really good. I use Announcements for most of my stuff because
you can have specific dependencies that don't need any monkey patching.
I didn't know SystemChangeNotifier but while you are hunting I want to
point you to EventManager which might be replaced after Announcements
found their way into the image.
Norbert
More information about the Squeak-dev
mailing list
|