{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

OOPs - Quality of a Class Abstraction Coupling Cohesion Why...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
10/7/09 1 Quality of a Class Abstraction: Coupling & Cohesion Michael L. Collard, Ph.D. Department of Computer Science The University of Akron Why Use Multiple Classes? Simplify testing Increase program understanding Increase reuse (internal and external) Reduce maintenance costs for fixes and enhancements Permit replacement Desired Class/Object Interaction Maximize internal interaction (cohesion) easier to understand easier to test Minimize external interaction (coupling) can be used independently easier to test easier to replace easier to understand Cohesion “degree of connectivity among the elements of a single module, and in object-oriented design, a single class/object” Internal measure: on a single class/object/module Very difficult to measure Cohesion Informational (best) Functional (best) Sequential (not bad) Communicational (not bad) Procedural Temporal Logical Coincidental (worst) Good (high) Bad (low) /* Joe's Stuff */ class Joe { public: // converts a path in windows to one in linux string win2lin(string); // number of days since the beginning of time int days(string); // outputs a financial report void outputreport(financedata, std::ostream&); };
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
10/7/09 2 Coincidental Cohesion Performs multiple, completely unrelated actions May be based on factors outside of the design: skillset or interest of developers avoidance of small modules No reusability Difficult maintenance or enhancement class Output { public: // outputs a financial report void outputreport(financedata); // outputs the current weather void outputweather(weatherdata);
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}