[squeak-dev] Abusing #userInterfaceTheme

St├ęphane Rollandin lecteur at zogotounga.net
Tue Sep 19 13:32:25 UTC 2017


> You do not know in advance how the object stored in a theme will be used 
> by the client. It is not always a simple instVar write.
> 
> Consider this example:
> 
> slider borderColor: ((self userInterfaceTheme borderColorModifier
> ifNil: [ [:c | c adjustBrightness: -0.3] ]) value: aColor).


This can easily be folded back into the getter/setter pattern:

	BorderedMorph>>borderColorModifier: aBlock
	    self borderColor: (aBlock value: self borderColor)

and then

	self borderColor: aColor.
	self getThemed: #borderColorModifier
		ifNone: [:c | c adjustBrightness: -0.3]


So I guess it's down to a design choice. I would vote for consistency of 
pattern, and having everything written in getter/setter pairs.


Best,


Stef


More information about the Squeak-dev mailing list