Coupling degree and polymerization degree

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.