tim Rowledge tim at
Wed Jan 4 19:55:08 UTC 2006

On 4-Jan-06, at 11:43 AM, Ramon Leon wrote:

> How about...
> (Dictionary new)
>     at: $c put: [self copy];
>     at: $x put: [self cut];
>     at: $v put: [self paste];
>     at: keyPressed ifAbsent:[].
Much more flexible to build a dictionary somewhere else  - class  
method perhaps - that is manipulable by some config tool. And  
sharable with other user methods. Then the 'doForKeyPress:' would be  
doForKeyPress: keyPressObject
   (self class keypressActions at: keyPressObject key ifAbsent:["do  
nothing but at least do it quickly"]) value

Sure this is a bit UI/keymap specific as an example but it's a common  
case where some body thinks a case statement is a good idea. They're  
not; I think I'd even claim they're never a good idea in Smalltalk.  
The really bad part is that they encode in the method everything you  
can do and allow for no expansion of customization - just another  
slave to the discredited early binding mentality that we should  
eschew at every (late) opportunity.

tim Rowledge; tim at;
Strange OpCodes: BBL: Branch on Burned out Light

More information about the Squeak-dev mailing list