是否可以在 BoUML 中清晰地建模地图?
Is it possible to model a map cleanly in BoUML?
考虑 UML Specification 的第 11.5.5 条中提供的合格关联的示例 11.37:
根据this answer 和其中规定的link,该模型应作为地图实现。但是当我尝试在 BoUML 中这样做时:
系统为 Bank
生成语法不正确的代码:
class Bank {
private:
map<Person *> accounts_;
};
假设我想制作这样的东西:
class Bank {
private:
map<AccountNo, Person *> accounts_;
};
作为一种解决方法,我可以使用 ${association}
并修改声明
${comment}${static}${thread_local}${mutable}${volatile}${const}${stereotype}<${association}, ${type} *> ${name}${value};
但这是错误的 - AccountNo
不是 AssociationClass。
Roundtrip 也没有产生合适的模型。
是否有实施 11.37 的简洁方法?
but this is wrong - AccountNo is not an AssociationClass.
我同意 AccountNo(只是一个数字),但是银行账户不仅仅是一个数字,它有一个名字,开户日期,可能是结束日期,可能是利息公式等
所以将帐户作为关系 -class 对我来说是正确的方法。
否则只使用帐号不使用关系-class并且不定义typedef,只使用银行和人之间的关系原型map 并将其默认定义修改为:
${comment}${static}${thread_local}${mutable}${volatile}${const}${stereotype}<int, ${type} *> ${name}${value};
假设银行账户是 int
如果你真的想指示键是一个 int
你可以使用其他构造型来指示(并配置如何在 C++ 中转换该构造型,或将 ${stereotype}
替换为 int
), 或者当然在图中使用注释
考虑 UML Specification 的第 11.5.5 条中提供的合格关联的示例 11.37:
根据this answer 和其中规定的link,该模型应作为地图实现。但是当我尝试在 BoUML 中这样做时:
系统为 Bank
生成语法不正确的代码:
class Bank {
private:
map<Person *> accounts_;
};
假设我想制作这样的东西:
class Bank {
private:
map<AccountNo, Person *> accounts_;
};
作为一种解决方法,我可以使用 ${association}
并修改声明
${comment}${static}${thread_local}${mutable}${volatile}${const}${stereotype}<${association}, ${type} *> ${name}${value};
但这是错误的 - AccountNo
不是 AssociationClass。
Roundtrip 也没有产生合适的模型。
是否有实施 11.37 的简洁方法?
but this is wrong - AccountNo is not an AssociationClass.
我同意 AccountNo(只是一个数字),但是银行账户不仅仅是一个数字,它有一个名字,开户日期,可能是结束日期,可能是利息公式等
所以将帐户作为关系 -class 对我来说是正确的方法。
否则只使用帐号不使用关系-class并且不定义typedef,只使用银行和人之间的关系原型map 并将其默认定义修改为:
${comment}${static}${thread_local}${mutable}${volatile}${const}${stereotype}<int, ${type} *> ${name}${value};
假设银行账户是 int
如果你真的想指示键是一个 int
你可以使用其他构造型来指示(并配置如何在 C++ 中转换该构造型,或将 ${stereotype}
替换为 int
), 或者当然在图中使用注释