About KCP and automatic initialize

ducasse ducasse at iam.unibe.ch
Mon Sep 15 06:40:27 UTC 2003


On Lundi, sep 15, 2003, at 08:01 Europe/Zurich, Richard A. O'Keefe 
wrote:

>     Problem:
> 	For many classes a parameterless #new (and correspondingly
> 	a parameterless #initialize) makes no sense.  The automatic
> 	inheritance of Object>>new, and the recent proposal to make
> 	that automatically invoke #initialize, make it far too easy
> 	for people to create incompletely initialised objects and
> 	encourage bad design.

This is Object class>>new


>     Solution:
> 	Change the browser so that when you create a new class
> 	the class method "new   self shouldNotImplement" with a
> 	suitable comment is automatically added, requiring explicit
> 	programmer action to *remove* this protection.

I'm against that.
There is no such a rule in Smalltalk. I can create a class and send new 
to the class
then I can get an inspector on it and start defining method.
This kind of ideas are good when you design up front your code, but 
they block
incremental programming. And again this is Object class>>new
So you have to explain to people ok
	- you have to write
		new
			super new initialize

	- but check before because it may be called before on the superclass

		do not forget ^ else you get the class
	
	- no	super new does not return an instance of the superclass
	
	- Yes new is a class method while initialize is an instance method

	- Do not forget to define your instance method back on the instance 
side (yes press that button)

Should I continue....

Richard what you want is defensive and good components. I agree with 
those goals. What we want is
to have a ***DEFAULT*** and simple instance initialization mechanism.

Stef

	



More information about the Squeak-dev mailing list