150 likes | 159 Views
Understand the domains of object classes - from foundation to application, business, and architecture. Explore class encumbrance and cohesion, measuring sophistication and interrelationships. Learn about low, medium, and high reusability across different industries and computer architectures. Discover the Law of Demeter and class cohesion concepts to enhance design quality.
E N D
Domain, Encumbrance, and Cohesion • Domains of Object Classes • application domain • business domain • architecture domain • foundation domain • Encumbrance • Class Cohesion
Foundation Domain • Classes used in different applications from different industries on different computer architectures • Classes of highest reusability • A foundation class may be built upon other foundation classes • Fundamental Classes - primitive types • Structural Classes - implementation of data structures • Semantic Classes - used conventionally
Architecture Domain • Usable in different applications from different industries • Reusability is limited to a single computer (hardware & software) architecture • Machine-Communication Classes • Database-Manipulation Classes • Human-Interface Classes
Business Domain • Useful in different applications within a single industry • Reusability may even limited to one corporation • Attribute Classes - properties of things • Role Classes - roles played in business • Relationship Classes - associations among things
Application Domain • Used only within a single application • Lowest reusability • Event-Recognizer Classes • event daemons • monitor input to check for occurrence of specific events in the environment • Event-Manager Classes • carry out business policy when an event of a given type occurs
Domains of Classes and Reusability Low Reusability • Application Domain • event manager classes • event recognizer classes • Business Domain • relationship classes • role classes • attribute classes • Architecture Domain • machine communication classes • database manipulation classes • human interface classes • Foundation Domain • semantic classes • structural classes • fundamental classes Medium Reusability High Reusability
Encumbrance • Quantitative Measure of Class Sophistication • Definition of Encumbrance in Object-Oriented Systems • Use of Encumbrance • Law of Demeter
Class Reference • Direct Class-Reference Set - the set of classes referred directly by a class (class C refer directly to D if:) • C inherits from D • C has an attribute of class D • C has an operation with an input argument of class D • C has a method that sends a message with a returned argument of class D • C has a method containing a local variable of class D • C supplies D as an actual class parameter to a parameterize class • C has a friend class D (in C++ only) • Indirect Class-Reference Set - union of direct class-reference sets
Definition of Encumbrance • Measures the total ancillary machinery of a class • comprises all the other classes that the given class must rely on in order to work • total number of classes referred (both directly and indirectly) to by the given class • Direct Encumbrance • size of its direct class-reference set • Indirect Encumbrance • size of its indirect class-reference set • Used to indicate class coupling
Use of Encumbrance • Measure of class sophistication • Higher domains have higher encumbrance • Unexpected encumbrance may indicate a fault in class design • low domain with high encumbrance => may have a problem with class cohesion • high domain with low encumbrance => lack of reusability
Law of Demeter • Guiding principle for limiting direct encumbrance of a class • Limitation of message receivers: • the object itself • an object referred to by a method signature • an object referred to by a variable (attribute) • current class only • current class plus inherited classes • an object created by a method • an object referred to by a global variable
Class Cohesion • Measure of interrelationship of attributes and operations located in the external interface of a class • Observe from outside instead of inside of the class • Three major cohesion problems • mixed instance • mixed domain • mixed role • A class may have more than one cohesion problem
Mixed-Instance Cohesion • A class has some features (attributes or operations) that are undefined for some objects of the class • Design problem of type definition • Usually involve redesign of the inheritance hierarchy
Mixed-Domain Cohesion • A class contains an element that directly encumbers the class with an extrinsic class of a different domain • Class B is extrinsic to A if A can be fully defined with no notion of B • Class B is intrinsic to A if B captures some characteristic inherent to A • Always include classes from lower domains because of intrinsic properties of the class
Mixed-Role Cohesion • A class contains an element that directly encumbers the class with an extrinsic class of the same domain • Depend on the basic definition (original representation) of the class • Least serious cohesion problem • may reduce reusability