gpt4 book ai didi

uml - 如何指定类的唯一标识符

转载 作者:行者123 更新时间:2023-12-02 03:08:58 25 4
gpt4 key购买 nike

我必须为 Employee 类指出每个员工都可以通过他的个人号码清楚地识别。不知道是不是我想得太复杂了,因为我没有真正的想法。

属性:最终 int 人员编号...

最佳答案

您甚至不需要 OCL 约束来在 UML 中表达这一点。Property 元类上有一个属性 isID 可以确保这一点:

摘自 UML 2.5 规范 § 9.5.3 (p. 111)

A Property may be marked, via the property isID, as being (part of) the identifier (if any) for Classifiers of which it is a member. The interpretation of this is left open but this could be mapped to implementations such as primary keys for relational database tables or ID attributes in XML. If multiple Properties are marked as isID (possibly in generalizing Classifiers) then it is the combination of the (Property, value) tuples that will logically provide the uniqueness for any instance. Hence there is no need for any specification of order and it is possible for some of the Property values to be empty. If the Property is multivalued then all values are included.

此属性的表示法与其他约束的表示法类似使用{id} 位于属性名称和类型之后

enter image description here

关于uml - 如何指定类的唯一标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58221092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com