Code 1:
class Wizard
{
public:
void castSpell();
}
class Man : public Wizard
{
}
Code 2:
class Magick
{
public:
void castSpell()
}
class Man
{
private:
Magick magick;
public:
void castSpell()
{
magick.castSpell();
}
}
In both cases, Man is a class that has the ability to cast a spell. In the first case, because man IS a wizard, in the second case because man HAS magick.
If I draw the first in a UML class diagram, then man inherits from Wizard so in EA, I then draw a "Generalize" connector from Man to Wizard. The "symbol" of the connector (a little triangle) is at the Wizard class.
In the second case, I draw a "Aggregate" connector from Magick to Man (instead of from Man to Magick). Now the "symbol" of the connector (a little diamond) is near Man!
So at an "is" relationship (Man is X), the connector symbol is at the X, while for a "has" relationship (Man has X), the connector symbol is instead at the side of Man.
I've always found this somewhat confusing, because "has" and "is" relationships are somewhat analogeous so I'd have expected an analogeous notation, but instead it's an opposite notation.
Also, sometimes a solution to the same problem can be done both with an is and a has relationship (such as the casting a spell above), but when drawing it in a UML diagram, the direction of the connectors has to be reversed for both.
And also, in all cases, it's MAN that depends on the other class (wizard or magick). But for the connectors, in the one case the symbol is at the side of that what depends, in the other case it's at the side of what is being depended on. That's also confusing to me.
What is the explanation why for such a has relationship, a connector is used where the symbol is near Man instead of at Magick? Am I thinking in a wrong way?
Thanks
