Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 SOFTWARE DESIGN QUALITY COHESION and COUPLING (Part II)

Similar presentations


Presentation on theme: "1 SOFTWARE DESIGN QUALITY COHESION and COUPLING (Part II)"— Presentation transcript:

1 1 SOFTWARE DESIGN QUALITY COHESION and COUPLING (Part II)

2 2 Quality Characteristics for Modules independent modules –avoid aggregation of multiple tasks per module –single-minded function ===> high COHESION –minimal interaction with other modules –simple interface ===> low COUPLING [Steven, Myers, Constantine]

3 3 Module COUPLING quality of interaction between modules based on module interfaces and types and number of connections coupling should be low types of coupling (high to low):

4 4 Content Coupling characteristics: –direct reference into another module –modification of called module at run-time example(s): –at calling time: jump to an address entry point –change local data of another module problems: –modules rely on each others internal structure –no clear interface - side effects –high degree of interdependency

5 5 Common Coupling characteristics: –sharing of a common, external data area –data area is unstructured example(s): –FORTRAN “COMMON” –C external data types problems: –M modules and N data elements: M x (M - 1) x N possible connections –high degree of (potential) interdependency

6 6 External Coupling characteristics: –sharing of a common, external data area –data area is structured example(s): –global data structures (variables) –communication to external tools and devices problems: –high potential for side effects –missing access control –modules are “bound” to the global structure

7 7 Control Coupling characteristics: –one module controls the execution path of another module via control flow (flag) example(s): –control parameter selects from a set of functions –error-checking decides on further execution problems: –the controlling module must have a minimum of knowledge about the controlled module –cohesion of the controlled module? (logical, procedural)

8 8 read & check registration reg_i 1 read registration 1.1 check registration 1.2 error-handler registration 1.3 reg_i reg_flag error_reason Control Coupling - control inversion

9 9 Stamp (Data) Coupling characteristics: –parameter passing of a complete data structure –only portions of the data structure are used example(s): –global, imported data structure declarations –copying real life limitations into your system problems: –change of data structure => change of module –module has to handle irrelevant information –module’s cohesion? (communicational, sequential,...)

10 10 Data Coupling characteristics: –parameter passing of (atomic) data elements –no unnecessary information –no control parameters –no external, shared data structures –independent and reusable –execute one single-minded function (good cohesion) problems: –cannot always be achieved

11 11 A good system design exhibits HIGH COHESION and LOW COUPLING

12 12 Cohesion & Coupling many times, high cohesion and low coupling complement and cause each other sometimes, high cohesion and low coupling contradict each other ===> the designer decides on the trade-offs

13 13 Cohesion & Coupling heuristics (sanitized experience) relative measures non-linear scale

14 14 Beyond Cohesion & Coupling Module size – objective: “understood without flipping the pages” – guideline: module size < statements on a page Fan-out (span of control): – objective : ”boss” modules should control a reasonable number of workers; – guideline: number of modules controlled by a “boss” < 7 Fan-in – objective: maximize fan-in, create generalized modules – guideline: modules must have strong or moderate cohesion (3) (4)

15 15 End of Section 4b


Download ppt "1 SOFTWARE DESIGN QUALITY COHESION and COUPLING (Part II)"

Similar presentations


Ads by Google