David
David

Reputation: 632

UML class diagram association properties {subsets < Association end > } | {union} | {redefines}

I don't quite understand what {subset} stands for when it comes to the association between class diagrams in UML. I've found this PDF that talks about it on page 4: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.138.5537&rep=rep1&type=pdf. Here is the diagram & text that you can also find on page 4:

enter image description here

I read this and I'm not 100% about what {subsets < class > } is about. It says that "The slot representing d will be a subset of the slot representing b. Elements of type B can be inserted into slot b and elements of type D can be inserted into slots b and d." So, is {subset} some kind of polymorphism ? I think that thorugh "slot" they mean like the argument of a method that is of type B. And because D subsets b that means that D is like the sub-class of b so it can be passed down as "b" in arguments because of Polymorphism.

So the question is : What is {subsets < class > } exactly, is it representing a sub class ?

On top of that I have other questions: What are {union}, {redefines < class > }, {nonunique} & {sequence}. What do does stand for ?

Some examples in code would make it easier to understand.

Upvotes: 2

Views: 674

Answers (1)

bruno
bruno

Reputation: 32596

So the question is : What is {subsets < class > } exactly, is it representing a sub class ?

It is not {subsets < class >} but {subsets < property name >}

In the given diagram D is the only visible class specializing B, and if they are no other classes specializing B then all the instances of B are instances of D and then {subset b} is equal to b.

But having at least :

enter image description here

all the instances of B are not necessary instances of D (including of classes specializing D), this is why d only concerns a subset of the instances of B concerned by b.

In your diagram and mine the subsets are not really useful, but there are for instance in case of redefinition e.g. {subsets a, redefines a} {subsets b, redefines b}


What are {union}, {redefines < class > }, {nonunique} & {sequence}

referring to formal/2017-12-05 §9.5.4 page 113 and 114 :

  • union means that the property is a derived union of its subsets.

  • nonunique: means that there may be duplicates in a multi-valued property. This is the opposite of unique meaning there is no possible duplicates. For instance supposing b is {nonunique} then some instances of B can be present several times in b. If the property is implemented in C++ by a std::set it is {unique}.

  • sequence means that the property represents an ordered bag, this is a shortcut of {nonunique, ordered}. This is the case of std::vector and std::list in C++.

  • {redefines < property-name > } (not {redefines < class >}) means that the property redefines an inherited property identified by < property-name >. If in your diagram the {subsets b} is replaced by {redefines b} then the classes C only has the slot (e.g. attribute in C++ etc) d. This is not like having b private so not accessible from C, that really means d is a redefinition of b.

Upvotes: 3

Related Questions