Java's modules rock? (was Re: election details)

Ron Teitelbaum Ron at USMedRec.com
Fri Mar 2 03:17:56 UTC 2007


> From: Michael van der Gulik
> 
> Personally, I don't think it's ever necessary to redefine methods in
> "System" objects such as Object, Collection or String. Other
> programming languages manage fine without being able to do this.
> 
> The most common reason people do this is to check if an instance is of
> a certain class (like Object>>isMorph or Object>>isMyStupidClass) -
> people should use isKindOf:. If that is too slow then isKindOf: should
> be made a primitive method.
> 
> Michael.
> 

I just did this right before I read this email.  I have a method
Object>>xmlContentString

It has a default implementation for every object in the system.  I need it
so that I can override the behavior of special objects.  I could move this
method to my xmlParser and write a case statement, or double dispatch with a
default on #respondsTo: #ifFalse, but it seems so much cleaner to put the
behavior on the objects themselves.  I agree it's not a good idea to extend
base objects arbitrarily but it does make the code much cleaner.  It makes
sense to be to put the behavior where it goes and let the polymorphism work
its magic.  

We could still verify base class implementations by isolating user
extensions or overrides to base classes.  Having this level of control is
really cool; I'd hate to lose it.

Ron Teitelbaum 




More information about the Squeak-dev mailing list