表示UML中的通用类继承 [英] Represent generic class inheritance in UML
问题描述
这是在UML类图中表示以下代码的正确方法吗?
Is this the correct way to represent the following code in a UML Class Diagram?
代码:
public class CustomerRepository
: EntityFrameworkRepository<Customer>, ICustomerRepository
{ }
UML:
推荐答案
编辑:
发布后实现的第一个答案不正确。 UML规范说(第7.3.4节):
Realised first answer wasn't correct after posting. The UML spec says (section 7.3.4):
绑定元素具有与其他
相同的图形标记。 TemplateBinding显示为虚线箭头,绑定元素的尾巴为
,模板为箭头,关键字为
«bind»。绑定信息可以显示为模板参数替换的逗号分隔
列表
A bound element has the same graphical notation as other Elements of that kind. A TemplateBinding is shown as a dashed arrow with the tail on the bound element and the arrowhead on the template and the keyword «bind». The binding information may be displayed as a comma-separated list of template parameter substitutions
我尝试在其中创建示例MagicDraw:
I tried to create an example in MagicDraw:
由于某种原因,它不允许我输入bind子句(虚线箭头中尖括号的内容):它应显示为< RepositoryType-> ;客户>
。同样, RepositoryType
参数也不应该是String类型(再次使用工具)。
For some reason it wouldn't let me enter the bind clause (contents of angle brackets on the dashed arrow): it should read <RepositoryType -> Customer>
. Also the RepositoryType
parameter shouldn't be of type String (tool again).
关键点是:参数绑定是在绑定关系上指定的,而不是在参数化的类中指定。这意味着您可以具有多个具有不同类型的绑定。
The key point is: the parameter binding is specified on the binding relationship, not in the parameterised class. Which means you can have multiple bindings with different types.
hth-对此致歉。
这篇关于表示UML中的通用类继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!