UML 2.5:包合并中名称相同但类型不同的属性会发生什么情况?
UML 2.5: What happens with attributes of same name but different type in a package merge?
我在官方文档中找不到答案(https://www.omg.org/spec/UML/2.5.1/)。当我合并两个包含同名 类 的包时会发生什么,这两个包包含同名但类型不同的属性。我们还假设这些属性有自己的 setter 方法。
UML 图:
UML (2.5) 说明了包合并(§ 12.2.3.3 通用包合并规则,第 242 页)
Matching typed elements (e.g., Properties, Parameters) must have
conforming types. For types that are Classes or Datatypes, a
conforming type is either the same type or a common supertype. For all
other cases, conformance means that the types must be the same.
所以因为 uniqueID
Integer 的类型不同或者是 String 的子类型,所以你的包合并是无效。
操作 setUniqueID(Integer)
不会造成问题,因为两个操作 setUniqueID(Integer)
和 setUniqueID(String)
可以作为重载操作共存。
我在官方文档中找不到答案(https://www.omg.org/spec/UML/2.5.1/)。当我合并两个包含同名 类 的包时会发生什么,这两个包包含同名但类型不同的属性。我们还假设这些属性有自己的 setter 方法。
UML 图:
UML (2.5) 说明了包合并(§ 12.2.3.3 通用包合并规则,第 242 页)
Matching typed elements (e.g., Properties, Parameters) must have conforming types. For types that are Classes or Datatypes, a conforming type is either the same type or a common supertype. For all other cases, conformance means that the types must be the same.
所以因为 uniqueID
Integer 的类型不同或者是 String 的子类型,所以你的包合并是无效。
操作 setUniqueID(Integer)
不会造成问题,因为两个操作 setUniqueID(Integer)
和 setUniqueID(String)
可以作为重载操作共存。