Download presentation
Presentation is loading. Please wait.
Published byKerry Lane Modified over 9 years ago
1
Jump to first page (C) 1998, Arun Lakhotia 1 Design Quality Metrics Arun Lakhotia University of Southwestern Louisiana Po Box 44330 Lafayette, LA 70504, USA arun@cacs.usl.edu
2
Jump to first page (C) 1998, Arun Lakhotia 2 Reference n Steve McConnell, Code Complete, Microsoft Press, 1993. u See Chapter 5 n Keywords u Cohesion u Coupling
3
Jump to first page (C) 1998, Arun Lakhotia 3 Aim n How do you compare design alternatives? n How do you critique a design? n What is Design? u Decomposition into functions u Decomposition into modules u Decomposition into classes
4
Jump to first page (C) 1998, Arun Lakhotia 4 Function Decomposition MainF2F1F3F4F5F6
5
Jump to first page (C) 1998, Arun Lakhotia 5 Reasons for creating routines n Reducing complexity n Avoiding duplicate code n Limiting effects of change n Hiding sequences n Improving performance n Making central points of control n Hiding data structures n Hiding global data n Hiding pointer operations n Promoting code reuse n Planning for a family of programs n Making code reusable n Improving portability n Isolating complex operations n Isolating use of nonstandard language n Simplifying complicated boolean tests n Modularization
6
Jump to first page (C) 1998, Arun Lakhotia 6 Quality of function decomposition n May be defined in terms of u Quality of individual functions F Measured as cohesion u Quality of interaction between functions F Measured as coupling n Desired decomposition u High cohesion u Low coupling
7
Jump to first page (C) 1998, Arun Lakhotia 7 Cohesion n How strongly internal components are related? n Poor/low cohesion: u A function does several unrelated activities u Removing one activity does not affect another activity n Good/High cohesion u A function performs activities that are related u Removing/changing one affects the other
8
Jump to first page (C) 1998, Arun Lakhotia 8 Acceptable cohesion n Functional cohesion u function performs only one activity n Sequential cohesion u Contains activities that are order dependent based on data flow n Communicational cohesion u Activities use the same data but are not otherwise related n Temporal cohesion u Activities to be performed at the same time (initialize, cleanup)
9
Jump to first page (C) 1998, Arun Lakhotia 9 Unacceptable cohesion n Procedural cohesion u Contains activities ordered on user interaction or directly dependent on requirements n Logical cohesion u Activities are mutually exclusive, selected on a flag n Coincidental cohesion u No apparent cohesion
10
Jump to first page (C) 1998, Arun Lakhotia 10 Interconnections between functions n Call n Called n Parameters passed n Global variables
11
Jump to first page (C) 1998, Arun Lakhotia 11 Coupling n How strongly are multiple functions related? n Strong relation, implies high coupling, implies poor code n Weak relation, implies low coupling, implies good code
12
Jump to first page (C) 1998, Arun Lakhotia 12 Acceptable coupling n Simple data coupling u data passed through parameters u data passed is not structured n Data structure coupling u Data passed through parameters u Data passed IS structured
13
Jump to first page (C) 1998, Arun Lakhotia 13 Unacceptable coupling n Control coupling u Data passed is used to make control decision n Global data coupling u Communicate through global variables n Pathological coupling u One routine modifies the code or data of another routine
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.