++
Navigating Associations.
If class A has an association with class B and x is an object in class A
then
x.b
is the assoicated elements in B to x (Note the shift to lower case).
If the association is many-to-one ( A *---1 B) then "x.b" is a single
object in B and you can do what you like with it.
If it is not many to one the "x.b" means a collection of elements.
Further operations work on all the elements and generates another collection.
It may be a vector, set, multiset, list, ... depending on the DCD.
Finally, you can write loop conditions to access each element if "x.b"
in turn
[for each y in x.b]
Of course, the actual data may be private, but we can always code a
"getter" function to navigate the association. So if A (*)-(1) B
then
x.getB()
is in the design or if A (*)-(*) B then
[for each y in x.getB()]
might be what you want. In either case your DCD ends up with
+ getB():B[*]
as an operation.
The coding will depend on the language and the precise type of collection
you choose. For example in C++ you need to explicitly code objects as pointers.
If we have chosen to implement the "*" as a vector you might even
(for example) code "*[for each b in x.b]b.zark()" like this:
vector<B*> myBs = x->getB();
for(int i=0; i< myBs.size(); i++)
mBs[i]->zark();