About KCP and automatic initialize

Roel Wuyts wuyts at iam.unibe.ch
Tue Sep 16 10:08:05 UTC 2003


On Monday, Sep 15, 2003, at 12:34 Europe/Zurich, Martin Wirblat wrote:

>> Sorry, but its part of the Smalltalk conventions to make new send
>> initialize (see the Kent Beck book about Smalltalk best practice
>> patterns).
>
>
> Nouri,
> would you agree that the _general_ Smalltalk convention in reality
> ( implementations, ANSI ) is that #new is not sending #initialize?

Again, this grew historically.... and historic choices or usefulness, 
however necessary and thought-over in their time, can turn out to be no 
longer valid currently. Hence we can change them. I refuse to let the 
library come to a standstill for *historic* reasons!

>
>
>>> There will be made many mistakes by those who are not accustomed to
>>> this behavior.
>>>
>>>
>> Its just a matter of documenting/learning. New users make mistakes...
>> That's natural.
>> Note however that avoiding this mistake can be enforced by the system.
>> When you
>> redefine #new in Squeak, an notification window appears saying that
>> its "dangerous" and
>> whether this is what do you want. We can extend this comment by
>> telling about the initialisation
>> pattern.... Hence, people can *not* forget it.
>>
>>> Additionally I think it is really easy to forget about it: If one
>>> plans to use #initialize for resetting or preparing later on etc,
>>> rather than for creating, it may not come to ones mind that during
>>> creation it is called too.
>>>
>>>
>> I'd rather suggest "reset" for a method doing resets... It reflects
>> better what a such method does...
>> One should keep "initialize" for initialization...
>>
>> Any way, we can not avoid people doing silly things (bad names, bad
>> desings, ...)...
>
>
> It is even more silly to explicitly call a super method and not to
> check on what it does, and yet as you found out, it happened 2 or 3
> times even in the standard image. Now have a look how often
> #initialize is send not during creation times and you will see that
> the semantics of #initialize in reality is not what your idea is
> implying: that it is only for creation. Practically speaking, it is
> not silly to think #initialize is part of and ONLY part of creation.
>
> To pop up warning-messages to prohibit the programmer from making some
> special mistakes out of a myriad of possible mistakes does not help.
> I guess this new-warning-dialog is more confusing than helpful for a
> beginner.
>
> An initialize-warning-dialog would be unhelpful too for beginners,
> annoying for others and hmm.. an indication for a wrong design
> decision? ( why do we have to pop up warnings for every method we want
> to write? is this a bad programming language? ).

Well, we currently do it every time I want to override #new........... 
:-(

>
> Furthermore you can turn your argumentation around: If you believe in
> warnings, it may be a better idea to remind the programmer with the
> new-warning-message not to double-send #initialize.

No, I agree, for me you do not need the warnings.

>
> Regards
> Martin
>
>
>
Roel Wuyts                                                   Software 
Composition Group
roel.wuyts at iam.unibe.ch                       University of Bern, 
Switzerland
http://www.iam.unibe.ch/~wuyts/
Board Member of the European Smalltalk User Group: www.esug.org



More information about the Squeak-dev mailing list