About KCP and automatic initialize
Richard A. O'Keefe
ok at cs.otago.ac.nz
Thu Sep 18 02:32:53 UTC 2003
ducasse <ducasse at iam.unibe.ch> wrote:
my gut feeling tells me that initialize is better because this is used.
No, that's why #initialize is *worse*. Chosing something that is used
is precisely what breaks things.
Choosing a *different* name is in your direct interests.
Why?
Step 1: Object class>>new ^self basicNew initializeYourself; yourself.
Step 2: Look for implementors of #initialize (other than the ones
for Class and Morph initialisation). For each one,
create the corresponding #initializeYourself.
Step 3: Look for senders of #initialize (other than the ones for
Class and Morph initialisation).. One by one, rip them out
or change them to send #initializeYourself, whichever is right
in context.
Step 4: Now that #initialize is only used for Class and Morph
initialisation, remove the other implementations.
At every step along the way, you have a working system. Not only that,
when you've finished, code *outside* the system that used #initialize
still works too. People who wish to adopt your pattern can freely do
so, following the same approach with their code working at every step
of the way.
Look at initializeInstance nobody uses it.
In 3.5-5180 (I still can't run 3.6 on my Solaris box), there are no
senders or implementors of #initializeInstance. Except for being harder
to say than #initializeYourself, that would make it a good choice.
Almost _anything_ would be a better name than one which is used so much
(and by so much code that relies on #new *not* sending that message).
More information about the Squeak-dev
mailing list
|