Simply put, the degree of coupling between objects is the dependence between objects. The main problem in guiding the use and maintenance of objects is the multiple dependencies between objects. The higher the coupling between objects, the higher the maintenance cost. Therefore, the design of the object should minimize the coupling between the class and the component.
Coupling is a measure of the correlation between modules in a program structure. It depends on the complexity of the interface between the modules, how the module is called, and what information is passed through the interface. There are seven possible connections between the general modules, the coupling from low to High is: non-direct coupling, data coupling, tag coupling, control coupling, External coupling, public coupling, content coupling, etc.
Aggregation (Aggregation):
This is a loosely-held relationship between objects. For example, a computer and his peripherals are examples.
Used to indicate the relationship between owning a relationship or the whole and part.
Combination (composition):
This is a very strong relationship between objects, for example, a relationship between a tree and its leaves.
In a composition, the part is the same as the whole life cycle. A synthetic new object completely has its composition
Part of the right to dominate. including their creation and destruction.
Finally, summarize:
Polymerization:
Aggregations can sometimes exist without relying on parts, and sometimes they cannot
Partial can exist independently of aggregation
If part of the loss, aggregation will give people an incomplete feeling
Partial ownership can be shared by several aggregates, such as printers
Synthesis:
Part of a moment can only belong to a certain composition
Make up the only one responsible for all the parts of it-that means responsible for their creation and destruction.
If part of the responsibility is borne by other objects, the composition can also relax these responsibilities.
If the composition is destroyed, it must destroy all the parts, or transfer the rights to other objects
Coupling degree and polymerization degree