About KCP and automatic initialize

Richard A. O'Keefe ok at cs.otago.ac.nz
Fri Sep 12 03:23:29 UTC 2003


Julian Fitzell <julian at beta4.com> wrote:
	Since you can create *any* object with a #new method I would
	argue that even *without* having #new call #initialize, most
	classes in Squeak can create a an unusable object.

That would be a sound argument if the premise were true.
It isn't.  It is NOT the case that "you can create *any* object
with a #new method".  Try (Boolean new) if you don't believe me.

When I devise a new class, I think very hard about whether it makes
sense to create one using #new with no extra information.  In the
common case that it doesn't, I explicitly install

    new
      self shouldNotImplement.

and then you _can't_ create objects of that class using #new.

Of course the usefulness of doing this is pretty much independent
of what Object new does.  But I find it such a useful bug avoidance
method that I have no qualms whatsoever calling #basicNew.



More information about the Squeak-dev mailing list