[squeak-dev] An old gripe (or: SystemChangeNotifier + Announcements = Sanity?)

Andreas Raab andreas.raab at gmx.de
Fri Mar 6 05:32:12 UTC 2009


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?

Cheers,
   - Andreas




More information about the Squeak-dev mailing list