Show in a UML class diagram that an aggregation is a subset of another

StackOverflow https://stackoverflow.com/questions/9905244

  •  27-05-2021
  •  | 
  •  

Pergunta

I have a class diagram with the following two aggregations:

Aggregations constraint problem

contentCategories is a dynamic array of categories, currentCategory is always an element of that array, but is maintained as a distinct member variable. I need to show the constraint that it is always an element of contentCategories in OCL. Have I done this correctly? If not, what would be the correct way to do it?

Thank you all for your help in advance!

Foi útil?

Solução

Yes, your idea is right. I would write the constraint in a comment, though, and w/o a dashed line

EDIT: sorry, in order to be "academically sound" your OCL constraint should also be correct even if there is no currentCategory. That means, the constraint'd better read

not currentCategory==null implies contentCategories -> includes(currentCategory)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top