gpt4 book ai didi

generics - 在 UML 中表示泛型类继承

转载 作者:行者123 更新时间:2023-12-05 04:17:54 28 4
gpt4 key购买 nike

这是在 UML 类图中表示以下代码的正确方法吗?

代码:

public class CustomerRepository 
: EntityFrameworkRepository<Customer>, ICustomerRepository
{ }

UML:

enter image description here

最佳答案

编辑:

发布后发现第一个答案不正确。 UML spec说(第 7.3.4 节):

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 中创建一个示例:

enter image description here

出于某种原因,它不允许我输入绑定(bind)子句(虚线箭头上尖括号的内容):它应该显示为 <RepositoryType -> Customer> .还有 RepositoryType参数不应该是字符串类型(又是工具)。

重点是:参数绑定(bind)是在绑定(bind)关系上指定的,而不是在参数化类中。这意味着您可以拥有不同类型的多个绑定(bind)。

hth - 对造成的困惑表示歉意。

关于generics - 在 UML 中表示泛型类继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20487455/

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