英文:
Using multiplicity without navigability in UML is correct diagram?
问题
I can see many UML example like above diagram.
I can understand that
- Class A has navigability to B with multiplicity of 10.
But I can't understand that - Class B has no navigability to A but has multiplicity of 5..7.
Is it possible has multiplicity without navigability in UML?
I can implement case 1 like below.
class A {
public:
B b[10];
}
But how can I implement case 2? No navigability but has multiplicity?
I am totally confused of case 2. What am I missing?
英文:
I can see many UML example like above diagram.
I can understand that
- Class A has navigability to B with multiplicity of 10.
But I can't understand that - Class B has no navigability to A but has multiplicity of 5..7.
Is it possible has multiplicity wihtout navigability in UML?
I can implement case 1 like below.
class A {
public:
B b[10];
};
But how can I implement case 2? No navigability but has multiplicity?
I am totally confused of case 2. What am I missing?
答案1
得分: 2
是的,可以在没有导航性的情况下拥有多重性。
导航性只是对在运行时轻松查找另一端的实例做出的承诺。没有导航性的承诺(甚至在另一端用X明确表示没有导航性)并不会改变关联的存在,因此也不会改变多重性。
第二种情况的实现,例如,可以使用在B中指向A的指针向量来实现导航回去(导航性会存在,但只是没有指示出来)。另一种实现方式可能是在A中使用指向B的指针向量,以便B可以被多个A共享,而其他机制确保它被3到7个A共享(没有导航性,但多重性被强制执行)。
英文:
Yes, it is possible to have a multiplicity without navigability.
Navigability only makes a promise about the ease at runtime to find instances at the other end. The fact the there is no promise on navigability (or even an explicit absence of navigability with a X at the opposite end) does not change the existence of an association and hence the multiplicity.
The implementation of 2) could for example be done with a vector of pointers to A in B to navigate back (the navigability would exist, but is simply not indicated). Another implementation coukd be to use in A a vector of pointers to B, so that B can be shared, and some other mechanism make sure it is shared by 3 to 7 A's (no navigability, but multiplicity enforced)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论