2

what is the difference between aggregation/composition and directional aggregation/composition in bouml?

directional aggregation/composition concepts are not found elsewhere except bouml and bouml does not explain in its site.

note: Code based explanations would be much better.

orkan
  • 512
  • 1
  • 4
  • 18
  • 3
    Duplicate of http://stackoverflow.com/questions/21967841/aggregation-vs-composition-vs-association-vs-direct-association – Sumeet Dec 22 '15 at 12:53
  • 1
    @Sumeet it's not a duplicate: the other question is about the difference between different types of association. Here it is about a property (unidirectional/bidirectional) that exists for each association (navigability) – Christophe Dec 22 '15 at 13:41

2 Answers2

6

According to the wording used by the site of the BOUML UML toolbox, "directional" has to be understood as "unidirectional" (opposed to "bidirectional") :

aggregation : to define a bi-directional aggregation, the code generators will produce two attributes whose names are the roles's name. This kind of relation may considered to be a shortcut to define two (directional) aggregations.

This "directional" term refers hence to navigation possibility between the related objects. For comparison, in MSVC2015 you find the notion of direction in the "Is Navigable" property of the association.

The unidirectional aggregation could therefore be for example:

class Member { ... };  // member of a club 
class Club {
   list<Members*> members; // you can go from Club to Members but not the contrary. 
   ...
};

The bidirectional aggregation should then be something like:

class Club; 
class Member {   // member of a club 
    list<Club*> clubs;  // club to which a membershib relation exist.  
    ...
};
class Club {
   list<Members*> members; // you can go from Club to Members and now back. 
   ...
};

For undirectional composition, we could have for example:

class Element { ... };  // Elemetn doesn't know parent (=> unidirectional)
class Object {
    vector<Element> element; // own by value for example
    ...
}; 

Or:

class Element { ... }; 
class Object {
    vector<unique_ptr<Element>> element; // ownnership by unique pointer 
    ...
}; 

Bidirectional composition could then be something like:

class Object; 
class Element {
    Object *parent;    //  you can navigate back (Element knows about parent)
    ...
 }; 
class Object {
    vector<Element> element; // own by value for example
    ...
}; 
Christophe
  • 68,716
  • 7
  • 72
  • 138
1

Christophe is right. Does this means that "directional" is a bad choice and it would be preferable to replace "directional" by "unidirectional" ?

Edit: some additional elements about terminolgy for the records

The UML standard v2.5 from OMG defines in section 11.5.Associations the principle of navigability:

Navigability means that instances participating in links at runtime (instances of an Association) can be accessed efficiently from instances at the other ends of the Association. The precise mechanism by which such efficient access is achieved is implementation specific. If an end is not navigable, access from the other ends may or may not be possible, and if it is, it might not be efficient.

The following wordings support the term "directional":

  • "The arrow indicates that the Association is to be read as associating the end away from the direction of the arrow with the end to which the arrow is pointing"
  • "Associations with navigability in both directions"
  • "has no directional significance" (in section 20.1.4 about another kind of diagram).

Nevertheless, in many places, the standard uses explicitely "unidirectional" and "bidrectional":

  • "In a diagram where arrows are only shown for one-way navigable associations, this probably signifies bidirectional navigability"
  • "These diagrams (...) may show navigability (by an open arrowhead) or nonnavigability (by an X) either always, only for unidirectional associations (oneWay), or never" (section B.3.2 about structure diagrams)
  • and many other places

So, while "directional" is perfectly valid, the term "unidrectional" may be a better an less ambiguous option.

Christophe
  • 68,716
  • 7
  • 72
  • 138
bruno
  • 32,421
  • 7
  • 25
  • 37
  • I guess from your name and firm affirmation that you are the author of BOUML. SO thank you very much for your confirmation ! I've edited your remark in order to provide terminological arguments for the two alternatives you've suggested. Hope this helps. – Christophe Dec 22 '15 at 20:26
  • Yes I am the author of Bouml ;-) – bruno Dec 23 '15 at 08:12