I am designing a program and I would like to make use of the composite pattern. I have noticed that there are two ways of expressing it:
and
What is the difference between the two? Thank you!
As @alper already states there is no real difference between both notations.
The top one allows navigation in both directions (so Component
can see Composite
namely as parent
) while the lower one does not have this navigability. To make make the missing parent
relation more obvious the author has added the arrow.
So the top one is a more universal implementation of the Composite pattern.