C # highly cohesive coupling (Analysis)

High cohesion and low coupling is determined the quality of software design criteria.
 

High cohesion, low coupling definitions:

Cohesion: each module independently as their function does not depend on external module code.                      

Coupling: the complexity of the interface between the module and the module, the more complex the higher the contact between the coupling module, indeed affect the whole body. 

Objective: such module "reusability", "portability" greatly enhanced 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

Cohesion

Cohesion is measured from a functional point of contact in the module, the module should be a good cohesion just do one thing, it describes the functional relationship inside the module.

Cohesion :

He said inner contact block, refers to a measure of the strength function module, an internal module based individual elements close to one another measure of the degree of binding.

If the individual elements within a module linked more closely, its cohesion is higher.

High cohesion:

Refers to a software module is a strong correlation between the composition of the code, is only responsible for one task, which is often said that the single responsibility principle. Cohesive Category: ↓

① occasional cohesion

There is no link between processing elements within a module, but accidentally get together. This module is also called a coincidence cohesion, a minimum degree of cohesion.

② The logical cluster

Put together several related functions, it is invoked each time, by the transfer module to determine which parameters to the function module to be completed.

③ time the poly

The module operation need to be performed in combination together to form a polymerization time module is called.

④ process within the poly

Simply means that if the processing elements within a module are related, and must be within polypropylene, is known as performed in a specific order.

⑤ communication within the 聚

It refers to the various components within data module using the same data structure or generating the same data structure. Sometimes referred to as the information together.

⑥ the sequential polymerization

A processing element of each module, and is closely related to a function, and these processes must be performed sequentially, after the input element of the one processing element output is typically a treatment before.

⑦ function within the poly

That module only includes all the ingredients necessary to complete a function, closely these ingredients, are indispensable.

Most cohesive.

Cohesion Summary:

When the module division, to follow the principle of "one module, a function", as much as possible to achieve the cohesion function module.

 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 


coupling

Is a measure of the coupling between the various software modules interconnected structure, the coupling strength depends on the complexity of the interface between the modules, or access point into the module and by a data interface.

Coupling:

He said inter-block connection, refer to the software system structure between the various modules interconnected a measure of the degree of confidentiality.

The closer links between the higher degree of coupling module, the module also worse independence.

Low degree of coupling between the modules depending on the complexity of the interface between the modules, the call mode, the information transfer.

Low coupling:

Simple to understand, between a complete systems, modules and modules, as much as possible so that independent existence.

Let each module independently of a specific sub-functions as possible.

Between the module interface should be as few and simple.

Coupled Category: ↑

① content coupling

Direct access to a content module of another module, called the two coupling modules content.

② common coupling

A module to access the same set of global data structure, is called common coupling.

③ external coupling

A set of modules are simple to access the same global variables, and do not pass through the information of the global variable parameter table, is called external coupling.

④ control the coupling

Not data transfer between the modules, but the control information such as a flag, switch, etc., a function of the control module of another module.

⑤ coupled tag

Call transfer between modules and the data structures are called modules rather than simply data, also referred to as coupling characteristics.

⑥ data coupling

Only simple transfer of data items between a calling module and a parameter module is invoked. Equivalent to the value passed high-level language.

⑦ indirect coupling

There is no direct relationship between the two modules, the connections between them are entirely controlled by the main module and the calling to achieve. Coupling the weakest, most independent module.

Coupled summary, there will be inevitable coupling between modules, but should follow:

① make use of the data coupling;

② reduction control coupling;

③ caution coupled to the public or the scope and limit the control of common coupling;

④ avoid content coupling.


The higher the degree of cohesion of each module in the program structure generally, the lower the degree of coupling between modules 

For the function is:

High cohesion: each member of the class method as a matter of only complete (maximum aggregation) 
low coupling: reduce internal class, a member of the other member of method invocation method 

For the class is:

The high cohesion and low coupling: reduce internal class, calls to other class

For a function block is:

Highly cohesive coupled: to reduce the complexity of the interactions between modules (interface number, parameter data)

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

Coupled to divide the degree of coupling therebetween from high to low as follows:

(1) Content coupling: a module to directly access the content of another module, called the two coupling modules of content.

When one of these occurs in the program, then the contents of the coupling between two modules:

  1. A direct access to the internal data module to another module.

  2. A module does not directly transferred to the inside of the other module via the normal inlet.

  3. Two overlapping part of the code module (the portion of the code has some independent function).

  4. A module has a plurality of inlets.

Content coupling can occur in assembly language. Most high-level languages ​​are designed to be coupled to the content is not allowed. This coupling is coupled strongest, weakest module independence.

(2) Public coupled: a module to access the same set of global data structure, is called common coupling. Public data can be global environment data structure, the communication area of ​​the shared memory of common coverage areas. If only the module data to the common data input environment, or retrieve data from only public data environment, which is a common loose coupling; if both extract data module and from the environment to the common data common data input environment data, which is a tighter common coupling.

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

Coupled problems caused by:

Maintainability poor, poor understanding, new functional module cumbersome.

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

----------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------------------------------------------- 

The advantages of high cohesion and low coupling:

In fact, short term, and there is no obvious advantage, even in the short term will affect the progress of the development of the system, because of the high cohesion, low coupling system development and design staff put forward higher requirements. High cohesion, low coupling benefits embodied in the process of sustainable development system, high cohesion, low coupling system has better reusability, maintainability, scalability, system maintenance can be done to develop more efficient and sustainable support the development of business, and will not become an obstacle to business development.

 


 




Guess you like

Origin www.cnblogs.com/Freedom0221/p/12596161.html