[Newbie] Morph class>>new

Anthony Hannan ajh18 at cornell.edu
Tue Apr 15 00:36:58 UTC 2003


Christian Hofer <Christian.Hofer at gmx.de> wrote:
> 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?

> >Object is not, but Object class is a subclass of Behavior.  When sending
> >a message directly to a class, ie. Object new, you are looking up
> >methods in its class, ie. Object class, which has a separate but similar
> >class hierarchy to Object.  Highlight the class button for any class in
> >the browser and choose 'show hierarchy' from the class pane menu. 
> 
> Ok. But why can't I see it with 'browse hierarchy' the same way (that's what
> I did)?

'browse hierarchy' ignores instance/class highlight and just shows the
instance hierarchy.  I guess the hierarchy browser designer figured that
since since you can see the class methods by hightlighting the class
button, you don't need to see them in the hierarchy list.

Cheers,
Anthony



More information about the Squeak-dev mailing list