Request and Pedidoitem establish a composition?

Asked

Viewed 174 times

3

I took the test of the IFSULDESTE competition of Minas Gerais organized by the CEFET-MG Foundation and I have doubts about the following question:

  1. Note the following class diagram.

Diagrama

About the diagram, it is INCORRECT to state that:

a) the methods obtainLimiteCredit defined in the Physical and Juridical classes are overloaded methods of the Person class.
b) in the association between the Physical and Juridical classes, the words "leader" and "director" represent the role that each class plays in this association.
c) the association between the Request and Pedidoitem classes is a composition.
d) the method obtainLimiteCredit of the Person class cannot be executed.
e) in the association between the Physical and Juridical classes, the expression "is administered by" represents the name of the association, and the arrow to the left of the expression represents the meaning of reading.

Source: CEFET Foundation. Available at: https://concurso.fundacaocefetminas.org.br/documentos/InformticaBomSucesso41637000719030930238.pdf. Accessed in: 31 Jul 2019.

I marked the letter A, because I understand that there is superscript and not overload of methods, in this case it would be the only incorrect option. However, the preliminary template identifies the letter C as the option that answers the question.

Why would the letter C be the correct option? The association between classes Pedido and PedidoItem is not composition?

2 answers

1

Graphic representation of composition (UML)

In the UML specification, version 2.5.1 (here), and from which the image provided below was extracted, the graphical notation used to represent a Composition is exactly that Request for Pedidoitem maid (black Diamond according to the quoted UML specification). See the example provided in the specification on page 187.

Additionally, in this same specification, the same black Diamond is the graphical notation used to represent a Composite Aggregation. In other words, in the specification, Composition and Composite Aggregation are employed to explain the same black Diamond, although the most employed term is Composite Aggregation.

See the example below, taken from page 207 and, of course, the caption.

inserir a descrição da imagem aqui Source: UML 2.5.1

Considering the above UML specification, as well as the figure, the black Diamond undoubtedly represents a Composite Aggregation (even because the term Composition is employed a few times and to explain the Composite Aggregation). That is, to know if composition is the same as Composite Aggregation, we need a reference in Portuguese duly accepted by both parties.

1


There are controversies about the letter A, so I find it at least dubious. At the same time contests usually provide literature to study that can say what is written there and it would be so that should respond, which shows that contest does not want who is enabled but who decorates certain things. I consider this option wrong, but it can be argued that it is still an overload if you consider that they are methods with different signatures, an invisible parameter, the this is different. But the overhead usually refers to the visible signature. But as I said it’s not something that has consensus. You could say both things happen.

And I would stay with her because C seems right to me, at least based on the answer I gave in What is the difference between Association, Aggregation and Composition in OOP?. The composition is the way to put related data directly and that could even be within the main object of so coupled that it is, ie you separate for better organization and who knows optimization (in some aspect), but deep down it belongs to the object, without this object the compound object cannot exist, which is exactly the case of items of a request, it only exists if the request exists, and has only been separated because it complicates a little having an undetermined number of items (has solution in a database, and even in memory in a very troubled way, but it is better to separate this part).

Perhaps it is just a confusion in the interpretation of the text, but if the text gives this margin it should not be valid. One of the reasons is that association and composition are antagonistic and the statement puts as complementary, it may be what makes it wrong, it would be a prank. One can ask for an argument because this "association is not a composition".

So I’d take Wikipedia and the links indicated there, would do one more research to confirm more and request annulment of the question, although they may claim that they used a specific literature that says otherwise, what I wanted to know.

Browser other questions tagged

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