About KCP and automatic initialize

ducasse ducasse at iam.unibe.ch
Wed Sep 10 07:06:07 UTC 2003


you can always do something wrong the automatic initialization does not 
help you there.


On Mercredi, sep 10, 2003, at 06:32 Europe/Zurich, Richard A. O'Keefe 
wrote:

> On further reflection, it seems to me that people *ought* to think
> carefully about initialising *each* class they write; a kluge in the
> kernel that makes it especially easy to do the wrong kind of 
> initialisation
> doesn't sound like much of a help.
>
> First off, the use of lazy initialisation means that many of the 
> classes
> I write would have no use whatever for an #initialize method.  Calling
> one would just slow them down.
>
> But second, the classes where I *do* need to initialise something 
> typically
> require at least one argument to say how to initialise.  Perhaps it's 
> my
> design style, but I really don't like setting things up so that clients
> have to do
>       x := HisClass new.
>       x addEyes: 3.
>       x giveName: #Triops.
>       x lickIntoShape
> I'd much rather they did
>       x := HisClass newNamed: #Triops withEyes: 3.
> A good example in the system would be
>     AliceActor newFor: anAliceWorld
> which calls #initializeFor:, not #initialize.
>
> I've forgotten, is there any reason to prefer
>     ^super new initialize
> to  ^self basicNew initialize
> The latter has the advantage of not repeating super initialize.
>



More information about the Squeak-dev mailing list