UML - Composition or Aggregation

Asked

Viewed 101 times

0

Is the related 'Composition' in the 'controlCurso' classes with the 'Course' carried out in this way? I am in doubt if it would be a 'Composition' or 'Aggregation', or none of them.

inserir a descrição da imagem aqui

1 answer

0


There is not only an always correct answer in this case. Everything will depend on the business rule, how it should be structured.

  • If your business rule specifies that controleCurso MUST HAVE one curso, cannot exist without one, so it is a COMPOSITION (Just like you did in the picture);

  • If your business rule specifies that controleCurso MAY OR MAY NOT HAVE one curso, can exist with or without one, so it is a AGGREGATION;

Taking into account the models presented in the image, I would leave as composition tbm. Because it does not make sense to exist a record of controleCurso with the fields presented, without there being a course for which it can relate. It is information necessary for it to exist.

Take a look at this site, it has more details and examples: https://www.ateomomento.com.br/uml-diagrama-de-classes/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.