[Q] initialization pattern

Noury Bouraqadi bouraqadi at ensm-douai.fr
Mon May 17 08:39:07 UTC 2004

stéphane ducasse wrote:

> On 16 mai 04, at 17:36, Boris Gaertner wrote:
>> With change set 5503 a new initialization pattern
>> was introduced: The method Behavior>> new
>> sends the message initialize to the newly created
>> instance. This has some advantages (also, but not only,
>> for teaching) and will hardly ever cause problems.
>> Interestingly, the object creation pattern for
>> variable subclasses was left unchanged: The
>> method Behavíor>>new: does not send the message
>> initialize to the newly created object.
> Seems to me a mistake because new: should call also initialize or may 
> be initialize: 

I agree, all newly created objects should be initialized whether they 
are variable or not.
But, only one initialization method should be used : #initialize 
(without any argument).
Cause variable classes can inherit from fixed classes. Having the same 
methods for initialization reduces risks of skiping initialization 
performed in the superclass since initialize methods perform a "super 
Besides, if the size of the new variable object is required, it can be 
retreived using message #size...


Dr. Noury Bouraqadi - Enseignant/Chercheur
Ecole des Mines de Douai - Dept. G.I.P

European Smalltalk Users Group

Squeak: an Open Source Smalltalk

More information about the Squeak-dev mailing list