Dave New
Dave New

Reputation: 40092

Represent generic class inheritance in UML

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

Upvotes: 5

Views: 3173

Answers (1)

sfinnie
sfinnie

Reputation: 9960

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.

Upvotes: 4

Related Questions