如何在UML中建模关联数组? [英] How to model associative arrays in UML?
问题描述
I know there are some related questions about this question, such as this, this and this, but no one of them really helped me. My array keys are dynamic, so I can't create an additional class holding this attributes (like done in second linked question).
我的概念的想法是持有类的实例,如下所示:
The idea of my concept is to hold instances of classes as follows:
$instances = [
"nameOfClass" => [
//instances of "nameOfClass"
],
"nameOfClass2" => [
//instances of "nameOfClass2"
]
//some more classes
];
但是当array-key与类名一致时,我不知道如何用UML为这些概念建模.
But I don't know how to model these concept with UML when the array-key is unanimously with the class-name.
有没有一种方法可以对我的概念/一般的关联数组进行建模?
Is there a way to model my concept/in general associative arrays?
推荐答案
用UML表示此问题的正确方法是使用限定符或限定的关联.那里您有一个拥有者,并且拥有一个与班级相关联的限定词(即键").此外,您可以给限定符指定一个类型,以表示您的键是某个类的String,int或Object.
The correct way to express this in UML is to use a qualifier, or qualified association. There you have an owner and that has a qualifier, i.e., "key", that associates to a class. Further you can give the qualifier a type, to express that your key is a String, int, or Object of a certain class.
另见p. UML 2.5的206.
See also p. 206 of UML 2.5.
这篇关于如何在UML中建模关联数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!