[squeak-dev] Subclassing OrderedCollection in an external package

Bert Freudenberg bert at freudenbergs.de
Tue Mar 5 22:22:49 UTC 2013


On 2013-03-05, at 23:06, tim Rowledge <tim at rowledge.org> wrote:

> On 05-03-2013, at 2:01 PM, Chris Muller <asqueaker at gmail.com> wrote:
> 
>>> P.S.: If XMLOrderedList is a subclass of OrderedCollection, then it's just
>>> plain wrong IMHO. Creating subclasses of collections in external packages is
>>> bad practice.
>> 
>> Hi Levente, I was just curious why that is bad practice.
> 
> I am also curious why you think that. Making subclasses is pretty much the essence of programming.

I'm curious why you would feel the need to subclass OrderedCollection, have to agree with Levente.

It's bad practice to subclass for no good reason, because you're much more likely to depend on the implementation details of your superclass, and not just its external interface. One shortcoming of Smalltalk in particular is that all the implementation details are visible, so they tend to get made use of. Which is perfectly fine for a personal computing system in one image, but not for a collaboratively maintained one, where we have to worry about breaking subclasses that are not in the image.

So feel free to subclass away, but be prepared for dealing with the consequences later. Strong coupling is bad, and subclassing creates a pretty strong bound.

- Bert -



More information about the Squeak-dev mailing list