[Q] initialize and initializeToStandalone

Ned Konz ned at bike-nomad.com
Wed Apr 17 14:32:01 UTC 2002

On Wednesday 17 April 2002 02:02 am, stephane ducasse (home) wrote:

> I have problem to understand the reason of existence of initialize
> and initializeToStandalone in Morph.

initialize is there to support Morph class>>new

and supports programmatic creation of default instances (i.e. to make 

initializeToStandalone is there to support Morph class>>newStandAlone

and supports user creation of default prototypes (from menus, Objects 
tool, etc.)

> This makes everything more complex. Even a stupid class such as
> flasherMorph
> duplicate completely the initialize method.....

You don't have to supply either method if you're happy with the one in 
Morph, which makes the bounds 50 at 40 and sets the color to the default 
color for your class.

But generally there is more initialization and building to do; 
initialize is a good place to put it.

For instance, if you have instance variables that should  start out 
their life as something other than nil, initialize is a good place to 
put them.

You can live without either method (I think) if you never try to 
create instances from the menu. However, I find it very useful to be 
able to "create sample instance" from the class browser.

If the concept of "default instance" doesn't make any sense, you 
probably want instead to make an initializer that takes parameters, 
and maybe a class side constructor that calls it.

Ned Konz

More information about the Squeak-dev mailing list