Represent generic class inheritance in UML

ⅰ亾dé卋堺 提交于 2020-04-11 12:06:13

问题


Is this the correct way to represent the following code in a UML Class Diagram?

CODE:

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

UML:

enter image description here


回答1:


EDIT:

Realised first answer wasn't correct after posting. The UML spec says (section 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

I tried to create an example in MagicDraw:

enter image description here

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 - apologies for the confusion.



来源:https://stackoverflow.com/questions/20487455/represent-generic-class-inheritance-in-uml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!