The topic is brought, but since I started studying UML for me it became one of the questions on which I can’t find a clear answer …
write that the relationship between the association, aggregation and composition is expressed as follows:
Association is a connection between classes, and the aggregation is the nesting of the same class to another, but at the same time the wrapper class does not control the lifetime lifetime (which is submitted by reference to the desired object).
It all clearly and understand its difference from aggregation. Nested objects should be created at the time of creating the container object and must be destroyed during the destruction of the container object. In opposition to her – the aggregation is underway when the object is transmitted according to the constructor, but still lives his own life.
Let’s start with the Association:
In This example The network shows a multiple association as an array of doctors at the class of patients and Opposite the massif of patients at the class of doctors.
I do not understand how it differs from the aggregation, except that only nested objects were not transmitted through the constructor, but the behavior is identical.
We also have an object wrapper and a container object. Container for doctors – class patients and vice versa. Not one of the containers does not manage the life lifespan that stores, otherwise it would be like a composition.
also does not understand the difference between the association and addiction. After all, the class container (reasoning does not apply to the above example) in any case, most likely it will most likely use the object to which stores it, it turns out that it is a dependent object, and the one that is stored in it – independent and from determining the relationship of dependence – between the elements There is a dependency when the changes in the definition of an independent element can cause changes in the dependent “, respectively, from the specified definition it follows that the association (as well as aggregation and the composition) always carries a relationship of dependencies correctly?
The classic example of aggregation always looks like the transfer of an attached object to the container object. Can the transfer of an attached object on the reference at the time of creating the object of the container to be considered a fundamental difference between the association and aggregation ???
Answer 1, Authority 100%
It seems everything is written here:
Composition is a relationship relationship. The part in the composition can be part of only one object at a time. For example: a uncle, which is part of the body of one person, can not be part of the body of another person at the same time.
Aggregation Unlike the composition, parts can belong to more than one for a whole , and , the whole does not control the existence and life time of parts . For example, the relationship between man and its home address. Each person has its own address. However, this address can belong to more than one person at a time: for example, you and your roommate or family members who live with you. However, this address can not be controlled by man – the address existed before people moved in and will continue to exist after the person evicted. In addition, a man knows, he lives what address, but the address, in turn, does not know what kind of person and in general, how many of them are there.
The association, in contrast to the composition or aggregation, which is part of the whole, objects to each other are not connected. Like the aggregation, the first object can belong to multiple objects at the same time and is not controlled by them. However, unlike aggregation, where one-way relationship in the association relationship can be either unidirectional or bidirectional (when both entities are aware of the existence of each other).