[Newbie] Morph class>>new

Christian Hofer Christian.Hofer at gmx.de
Tue Apr 15 08:53:35 UTC 2003


> > Or would it crash my system if I would change:
> > Morph class>>new
> > to:
> > ^self basicNew initialize
> 
> Since "super new" (Behavior>>new) calls the same primitive as "self
> basicNew" (Behavior>>basicNew) you would get the same effect.
> 
> > (I haven't dared yet.) I mean, this is simply what I have read in Kent
> > Beck's Best Practice Patterns (IIRC), that 'super new initialize' has
> the
> > disadvantage that it forbids me to override this method in a subclass,
> if I do not
> > want "initialize" to be called more than once.
> 
> I don't follow.  Why can't you override it and call super or call
> initialize yourself?

An Example of what I mean:
It says in the Squeak-code:
Morph class>>new
  ^super new initialize

Morph is a subclass of Object. If someone picked up the proposal of Stephane
to initialize all objects, and e.g. inserted a:
Object class>>new
  ^super new initialize
into the image, then:
Morph new openInWorld
would twice initialize the Morph. This would not happen if Morph used:
self basicNew initialize

Is that wrong?

Christian

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!



More information about the Squeak-dev mailing list