[Pharo-project] Smells looking at collections

Levente Uzonyi leves at elte.hu
Fri Oct 22 08:54:20 EDT 2010


On Fri, 22 Oct 2010, Nicolás Paez wrote:

> Hi, I was looking at collection packages and I found that the class
> Association inherits from Magnitude.
> It is really strange for me because inheritance represent a "is-a" relation.
>
> So I looked that the documentation of each of these classes:
>
> *Association:* I represent a pair of associated objects--a key and a value.
> My instances can serve as entries in a dictionary.
>
> *Magnitude:* I'm the abstract class Magnitude that provides common protocol
> for objects that have
> the ability to be compared along a linear dimension, such as dates or times.
> Subclasses of Magnitude include Date, ArithmeticValue, and Time, as well as
> Character and LookupKey.
>
> Based on this, I think this relation is conceptually WRONG.
> If the idea is to reuse code then composition should be used instead of
> inheritance.
>
> What do you think?

This was the original hierarchy: Magnitude -> LookupKey -> Association. 
Someone removed LookupKey from the chain. This was LookupKey's comment:

"I represent a key for looking up entries in a data structure. Subclasses 
of me, such as Association, typically represent dictionary entries."


Levente

>
> Saludos!
> Nico.
> blog: nicopaez.wordpress.com
>


More information about the Pharo-dev mailing list