Coupling problems between modules

Source: Internet
Author: User
Brief IntroductionThere are seven possible connection modes between general modules, and seven types of coupling are formed. The relationship between them is (independence from strong to weak) Non-direct coupling (nondirect coupling)If there is no direct relationship between the two modules, the connection between them is entirely achieved through the control and invocation of the main module, which is indirect coupling. This coupling module has the strongest independence. data Coupling (coupling)When one module accesses another module, it is said that the coupling is data coupling by exchanging input and output information between each other through data parameters (not control parameters, public data structures, or external variables). Because it restricts the data passing through the parameter table, the program interface developed by data coupling is simple, safe and reliable. As a result, data coupling is loosely coupled, and the independence between modules is relatively strong. At least this type of coupling must be in the software program structure. Imprint Coupling (Stamp coupling)If a group of modules passes record information through the parameter table, it is tag coupling. In fact, this group of modules shares this record, which is a substructure of a data structure, not a simple variable. This requires that the modules be clear about the structure of the record, and that the record is manipulated as required by the structure. This coupling should be avoided as far as possible in the design, which complicates the operation of the data structure. If the "Information concealment" method is adopted, the operations on the data structure are all concentrated. controlling coupling (control coupling)If a module through the transmission of switches, flags, names and other control information, obviously control the choice of another module function, is the control of coupling. The essence of this coupling is to select a function in a multifunction module on a single interface. Therefore, any modification to the controlled module will affect the control module. In addition, the control coupling also means that the control module must know some logical relationships within the control module, which will reduce the independence of the module. external coupling (External coupling)A set of modules that access the same global simple variable instead of the same global data structure, and not pass the information of the global variable through the parameter table, are called external coupling. For example, each module in the C language program accesses an external variable that is described as an extern type. External coupling causes problems similar to public coupling, except that there is no physical arrangement in the external coupling that relies on a data structure. Public coupling (Common coupling)If a group of modules have access to the same public data environment, the coupling between them is called a public coupling. The public data environment can be a global structure, a shared communication area, a public coverage area of memory, and so on. This coupling causes the following problems: All public coupling modules are related to the physical arrangements within a common data environment, and modifying the size of a particular data will affect all modules. It is impossible to control the access of each module to public data, which seriously affects the reliability and adaptability of the software module. The use of public data names significantly reduces the readability of the program. The complexity of public coupling increases significantly with the number of coupled modules. If there is only a common data environment between two modules, there are two scenarios for public coupling. If a module only transmits data to a common data environment, and the other module simply takes data from a public data environment, the public coupling is called loosely-coupled. If all two modules take data from the public Data environment and send the data to the public data environment, the common coupling is called tight public coupling. Public coupling is only used when there is a lot of data that is shared between modules and is not convenient to pass through parameter tables. Otherwise, it is better to use the data coupling of module independence relatively high. content Coupling (coupling)Content coupling occurs between two modules if the following conditions occur. One module directly accesses the internal data of another module; a module does not go through the normal entrance to another module; two modules have a portion of the program code overlap (which can only occur in assembly language); A module has multiple portals. In the case of a content coupling, any changes to the module being accessed or compiled with a different compiler can cause a program error. Fortunately, most advanced programming languages have been designed to not allow content coupling to occur. It usually appears in the assembly language program. This coupling is the weakest coupling of module independence.

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.