Friday, April 08, 2005

wxMorphic Update v0.04alpha

Steven Swerling has announced an update (v0.04alpha) to wxMorphic for Squeak. It implements Doug Ways suggestion of SystemWindows popping up in their own OS window and includes an additional launcher window. Click on the screenshot to enlarge or visit the project page to download.

Wednesday, April 06, 2005

Teaching Behavior

I cleaned up some old VisualWorks code I had from Ernest Micklei and published it to the Cincom Public Repository. Watch out for a "Teachable" package.
It's another nice example how powerfull Smalltalk really is. It's an implementation of a Teachable class who's instances can be teached to respond to messages. It's usefull for creating mocks who should behave like other objects (for instance inside of a test case) without actually implementing a real mock class. Here is an example how it can be used:

|teachable|
teachable := Teachable new.
teachable
    whenSend: #help return: 'ok';
    whenSend: #doit evaluate: [1 inspect];
    acceptSend: #noDebugger;
    whenSend: #negate: evaluate: [:num num negated].

After teaching the object we can use it as if it had a normal implementation in a class:

teachable help. "this will return the string 'ok'"
teachable doit. "this will open the inspector on the SmallInteger 1"
teachable noDebugger. "this will accept the send of #noDebugger and return the teachable"
teachable negate: 120 "this will return -120"

A Squeak version of the code can be found here.