[DOCS] ProtoMorph (was: Thinking about redoing Morphic)

Hannes Hirzel hannes.hirzel.squeaklist at bluewin.ch
Thu Feb 13 09:15:45 UTC 2003

Hi all

Todd Blanchard sent in a very nice tiny changeSet named

It takes Alejandro F. Reimondos idea of cloning applied to just one
class - the class Morph
It  includes the notion of adding methods as you go along 
worked on by Andrew P. Black, Adam Spitz and Ned Konz in another thread
'adding methods to the debugger'
but in this case automatically by copying the missing methods from
another class.

I tried it out and it worked excellently well.

Below are some notes I did.



The changeset only includes class ProtoMorph with 7 (seven) methods. The
most important one is

doesNotUnderstand: aMessage 

	Morph sourceCodeAt: (aMessage selector) ifAbsent: [ super
doesNotUnderstand: aMessage].
	self cloneSelector: (aMessage selector).
	^self perform: (aMessage selector) withArguments: (aMessage arguments).

It basically copies the methods not known to ProtoMorph from the Morph
class itself.

Using ProtoMorph

Open a new MorphicProject

File in MinimalProtoMorph.1.cs

Open a Workspace

   ProtoMorph new openInWorld
and evaluate it

A debugger window pops up with an error message in method #wantsSteps
Comment out the code in #wantsSteps in ProtoMorph in a SystemBrowser 
(important: not in the debugger that doesn't work in this case)
and add 


	ProtoMorph new openInWorld
This time the process is completed and you get a new ProtoMorph at the
default position
(upper left corner) in the default color (blue)

(Actually you have two ProtoMorphs as you find out if you bring up the
halos by clicking the blue button and moving them.

In the Workspace type
  ProtoMorph methodDict size 
and evaluate and print it 

You get 172 methods  (in Squeak 3.5a)

This whole process makes understanding the
class Morph much more tackable.

Browse ProtoMorph in the SystemBrowers 
It is an interesting experience

Bring up the halos of a ProtoMorph again
and resize the ProtoMorph

	ProtoMorph methodDict size  
And you get 186 methods

Bring up the halos again and choose the 
recolor handle
	ProtoMorph methodDict size  
And you get 190 methods.

If you embed one ProtoMorph in another morph
the number of methods augments to 256.

And so one ...


I consider ProtoMorph to be a good learning and
documentation aid. It surely helps the refactoring process.

Many method categories of ProtoMorph 
include only one or two methods. They often are actually the 
"hooks" to entire subsystems.

This process elaborated a bit further may allow you to 
come up with  your own NewMorph hierarchy which includes 
only the things you want.

More information about the Squeak-dev mailing list