问题
Is this the correct way to represent the following code in a UML Class Diagram?
CODE:
public class CustomerRepository
: EntityFrameworkRepository<Customer>, ICustomerRepository
{ }
UML:
回答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:
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