About KCP and automatic initialize

Noury Bouraqadi bouraqadi at ensm-douai.fr
Mon Sep 15 07:57:20 UTC 2003



Richard A. O'Keefe wrote:

>Avi Bryant <avi at beta4.com> wrote helpfully about the initialisation/
>creation conventions for FoundationKit for Objective C.
>
>  
>
>>>>>>	- The designated initializer must call its superclass' designated  
>>>>>>            
>>>>>>
>	initializer.
>	...
>
>	So, the short answer to Julian's question is: yes, use #basicNew in  
>	#forClass:.  If you make sure to follow the rest of these conventions,  
>	the problems that people have with #basicNew (in terms of missing  
>	superclass initialization) should not come up.
>	
>There is an implicit assumption here, which is that superclass
>initialisation is always (but ALWAYS) appropriate for subclasses.
>
>This is very often true.  One might even say that it is usually true.
>But in a language like Smalltalk, where the superclass initialisation
>method may call instance methods that are overridden by the subclass,
>it is certainly not a *safe* assumption.
>  
>
But, this is always the case when overriding instance methods.
Its not specific to initialization.

>I don't want to be misunderstood as claiming that you _often_ want to
>bypass an inherited initialisation method, only that it is _sometimes_
>legitimate to do so, and if you are forbidden to do this by your language
>or library, then you have to drive a wedge between what the _language_
>called "initialization" and the _real_ initialisation, which means that
>there's an interval when an object is accessible and "initialized"
>but not _really_ initialised.  And that's not usually desirable.
>
>  
>
You can do it whithin the new-initialize pattern by redefining the 
initialize in your subclass and *whithout* making it send "super 
initialize".
Another solution is applicable when the #initialize method provided by 
the superclass is a template method i.e., it send various messages to 
self to peform initialization tasks. In this case, one can just override 
the appropriate methods.

Any way, you are speaking about "sometimes" which refer to some special 
(rare) cases.
These should not forbide us from having the new-initialize pattern be 
system wide.

Noury

-- 
------------------------------------------
Dr. Noury Bouraqadi - Enseignant/Chercheur
Ecole des Mines de Douai - Dept. G.I.P
http://csl.ensm-douai.fr/noury

European Smalltalk Users Group
http://www.esug.org 

Squeak: an Open Source Smalltalk
http://www.squeak.org 
------------------------------------------





More information about the Squeak-dev mailing list