1 / 48

Measuring Class Coupling and Cohesion: A Formal Metamodel Approach

Measuring Class Coupling and Cohesion: A Formal Metamodel Approach. by Simon Moser and Vojislav B. Misic (1997) Synopsis by Rand Williams. Abstract. This presents software quality metrics : Coupling Cohesion Defined in the terms of

abiola
Download Presentation

Measuring Class Coupling and Cohesion: A Formal Metamodel Approach

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. Measuring Class Coupling and Cohesion: A Formal Metamodel Approach by Simon Moser and Vojislav B. Misic (1997) Synopsis by Rand Williams

  2. Abstract • This presents software quality metrics: • Coupling • Cohesion • Defined in the terms of • Functional Dependencies in a Formal Metamodel of Object-Oriented Systems

  3. Contents • Introduction • Model Definition Part I • Model Definition Part II • Measuring Design Quality • Component Sizes • Coupling • Cohesion • Experiment and Explanation • Conclusion

  4. 1. Introduction What are Software Quality Metrics • Software Quality Metrics are used • To measure design quality • To estimate, monitor, and control quality

  5. 1. Introduction What are Formal methods • Formal methods • Mathematical language • Express system structure and behavior • The authors of this paper use Z

  6. 1. Introduction What is Meta-Modeling • Meta-Modeling is an iterative method of • Model Definition • Model Refinement • Definitions are layered, i.e. compositional • Abstract refined to specific

  7. 2. Model Definition Part I • Abstract Formal-Metamodel • Structure of interrelated objects • Object is defined by • Interfaces (structure) • Implementations (behavior)

  8. 2. Model Definition Part I • The External Part (ExtPart) of an object • Interface used for • communication with other objects • represents the object • The Internal part (IntPart) of an object • Implementation

  9. 2. Model Definition Part I • Object must have one or both: • Interface • Implementation

  10. 2. Model Definition Part I • Objects define other objects • Relations: defines, use and usedBy

  11. 2. Model Definition Part I • Object encapsulation: contained objects retain their identity and are not a part of the container; for instance, a member variable.

  12. 2. Model Definition Part I • Uniqueness • Contained objects areunique within their container

  13. 2. Model Definition Part I

  14. 3. Model Definition Part II • General Formal-Metamodel • For object-oriented systems • Abstract model is refined • Add concepts of object-oriented systems • Classes • Features • Inheritance

  15. 3. Model Definition Part II • Classes and Features • Types of the objects • Feature is a Variable or Method

  16. 3. Model Definition Part II • Inheritance subset of defines relation • Relations: • parentOf (many to one) • Children (one to one (set))

  17. 3. Model Definition Part II • Inheritance of Features • Transitive closure inheritedTo • Over the parentOf and classOf • Tells which features are defined for any particular child class

  18. 3. Model Definition Part II

  19. 4. Measuring Design Quality • Coupling and Cohesion • Used for assessing system design quality for more than two decades • Industry Wisdom: “the [system] with the lower coupling and higher cohesion is of better quality.”

  20. 4. Measuring Design Quality • General definition of Coupling • Coupling = the (relative) degree of dependence of one object on another • Example: The (relative) amount that PlanetaryScale class depends on the Astronaut class

  21. 4. Measuring Design Quality • General definition of Cohesion • Cohesion = the (relative) degree to which ‘all elements of an object contribute to performing a single well defined function’ • Example: The (relative) amount that Astronaut class is defined within itself.

  22. 4. Measuring Design Quality • 4.1. Calculating component sizes • External size • Internal size • Total size • The total size of any object • Sum of Internal and External

  23. 4. Measuring Design Quality • The external size • Effort required to use object • Correlates to size of interface • For a library or project objectIf has interface, size is sum

  24. 4. Measuring Design Quality • For a library or project objectIf no interface, size is 1

  25. 4. Measuring Design Quality • The internal size • Effort to implement object • For a project object • Sum of external sizes of defining objects

  26. 4. Measuring Design Quality • For a language or library object • Internal size is 0 • For a language object • External size is 1

  27. 4. Measuring Design Quality • 4.2. Class coupling • Active Coupling • Passive Coupling • Coupling measures the degree of dependence of a given object on other objects

  28. 4. Measuring Design Quality • Active Coupling • External size of C2 relative to Internal size of C1

  29. 4. Measuring Design Quality • Passive Coupling • Amount of External size of C1 relative to total External size of C1, used in C2

  30. 4. Measuring Design Quality • 4.3. Class Cohesion • Internal Cohesion • External Cohesion • Cohesion denotes the degree to which ‘all elements of an object contribute to performing a single well defined function’

  31. 4. Measuring Design Quality • Internal Cohesion • Amount of Coupling of object to itself

  32. 4. Measuring Design Quality • The Siblings of a feature • The set of other features contained in the same class

  33. 4. Measuring Design Quality • Measurement Sigma is similarity of usage of a feature relative to that of its siblings

  34. 4. Measuring Design Quality • The External Cohesion • The average similarity of the usage of the class’s features

  35. 5. Experiment and Explanation • The authors perform a simple empirical experiment on a set of Java classes • A utility class Astronaut • A main class PlaneteryScale

  36. 5. Experiment and Explanation • The authors perform a simple empirical experiment on a set of Java classes • A utility class Astronaut • A main class PlaneteryScale

  37. 5. Experiment and Explanation • The PlanetaryScale class • contains an instance of the Astronaut class (as a variable = a Feature) class PlaneteryScale { private Astronaut armstrong; … }

  38. 5. Experiment and Explanation • The PlanetaryScale class • Uses Features (methods) of Astronaut in several of its own features class PlaneteryScale { void calculateWeight() { armstrong = new Astronaut (getEarthWeight()); } … }

  39. 5. Experiment and Explanation • The Astronaut class • Does not contain PlanetaryScale class • Does not use PlanetaryScale class

  40. 5. Experiment and Explanation • Coupling and Cohesion measuresAstronaut and PlanetaryScale classes

  41. 5. Experiment and Explanation • Active Coupling – inter-dependency 20% of PlanetaryScale is Astronaut0% of Astronaut is PlanetaryScale

  42. 5. Experiment and Explanation • Passive Coupling – efficiency of use71% Astronaut used in PlanetaryScale0% PlanetaryScale used in Astronaut

  43. 5. Experiment and Explanation • Internal Cohesion – self definition50% of Astronaut defined in itself33% of PlanetaryScale defined in itself

  44. 5. Experiment and Explanation • External Cohesion – feature average67% Astronaut 97% PlanetaryScale • The average similarity of the usage of the class’s features

  45. 6. Conclusion • Measuring Class Coupling and Cohesion: A Formal Metamodel Approach by Simon Moser and Vojislav B. Misic presents • General Formal Metamodel of OO systems • Definition of software quality metrics, Coupling and Cohesion • For use in measuring design quality

  46. 6. Conclusion • Readers opinion: • “Although the metrics and definitions appear thorough, the paper is very light in empirical research, results, and explanations. Further analysis of the definitions and implications would be required, in this readers opinion, to validate and verify both the accuracy and utility of the defined model and metrics.”

  47. Questions and Comments

  48. References • Moser, S.; Misic, V.B.; , "Measuring class coupling and cohesion: a formal metamodel approach ," Software Engineering Conference, 1997. Asia Pacific ... and International Computer Science Conference 1997. APSEC '97 and ICSC '97. Proceedings , vol., no., pp.31-40, 2-5 Dec 1997doi: 10.1109/APSEC.1997.640159 URL: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=640159&isnumber=13814

More Related