Is it possible to model a map cleanly in BoUML?

Viewed 56

Consider an example 11.37 of the qualified association provided in clause 11.5.5 of UML Specification:

enter image description here

It follows from this answer and the link provided therein that this model should be implemented as a map. But when I try to do it in BoUML:

enter image description here

the system generates code for Bank which is not syntactically correct:

class Bank {
  private:
    map<Person *> accounts_;
};

Suppose I want to produce something like that:

class Bank {
  private:
    map<AccountNo, Person *> accounts_;
};

As a workaround I could, say, use ${association} and modify the declaration

${comment}${static}${thread_local}${mutable}${volatile}${const}${stereotype}<${association}, ${type} *> ${name}${value};

but this is wrong - AccountNo is not an AssociationClass.

Roundtrip does not produce a suitable model too.

Is there a clean way to implement 11.37?

1 Answers

but this is wrong - AccountNo is not an AssociationClass.

I agree for AccountNo (just a number), but a bank account is not only a number, it has a name, open date, may be end date, may be interest formula, etc

So to have Account as a relation-class is the right way for me.

Else using only an account number do not use a relation-class and do not define that typedef, just use a relation between Bank and Person stereotyped map and modify its default definition to have :

${comment}${static}${thread_local}${mutable}${volatile}${const}${stereotype}<int, ${type} *> ${name}${value};

supposing the bank account is an int

If you really want to indicate the key is an int you can use an other stereotype indicating that (and configure how to translate that stereotype in C++, or replace ${stereotype} by int), or of course use a note in the diagram

Related