1 / 15

SOFTWARE DESIGN QUALITY

SOFTWARE DESIGN QUALITY. COHESION and COUPLING (Part II). 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

brendaadams
Download Presentation

SOFTWARE DESIGN QUALITY

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. 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. 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. 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. 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. 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. Control Coupling - control inversion read & check registration 1 reg_i error_reason reg_i reg_flag read registration check registration error-handler registration 1.1 1.2 1.3

  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. 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. A good system design exhibits HIGH COHESION and LOW COUPLING

  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. Cohesion & Coupling • heuristics (sanitized experience) • relative measures • non-linear scale

  14. Beyond Cohesion & Coupling • Module size • objective: “understood without flipping the pages” • guideline: module size < 30-50 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. End of Section 4b

More Related