Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the arrow go up in inheritance?

When you draw an inheritance diagram you usually go

                         Base
                           ^
                           |
                        Derived

Derived extends Base. So why does the arrow go up?

I thought it means that "Derived communicates with Base" by calling functions in it, but Base cannot call functions in Derived.

like image 747
bobobobo Avatar asked Mar 18 '10 16:03

bobobobo


4 Answers

In UML the arrow is called a "Generalization" relationship and it only signals that each object of class Derived is also an object of class Base.

From the superstructure 2.1.2:

A Generalization is shown as a line with a hollow triangle as an
arrowhead between the symbols representing the involved classifiers.
The arrowhead points to the symbol representing the general 
classifier. This notation is referred to as the “separate target style.”

Not really an answer though to the question :-)

like image 172
Christopher Oezbek Avatar answered Oct 19 '22 10:10

Christopher Oezbek


AFAIK one of the reasons is notational consistency. All other directed arrows (dependency, aggregation, composition) points from the dependant to the dependee.

In inheritance, B depends on A but not vice versa. Thus the arrow points from B to A.

like image 43
Péter Török Avatar answered Oct 19 '22 11:10

Péter Török


Read the arrow as "inherits from" and it makes sense. Or, if you like, think of it as the direction calls can be made.

like image 39
Devon_C_Miller Avatar answered Oct 19 '22 12:10

Devon_C_Miller


I always think of it as B having more stuff in it then A (subclasses often have more methods than superclasses), hence B gets the wide end of the arrow and A gets the pointy end!

like image 23
John Topley Avatar answered Oct 19 '22 12:10

John Topley