Upload
myra-casey
View
235
Download
0
Embed Size (px)
Citation preview
4-4-11
Domain, Encumbrance, Domain, Encumbrance, and Cohesionand Cohesion
• Domains of Object ClassesDomains of Object Classes– application domain– business domain– architecture domain– foundation domain
• EncumbranceEncumbrance
• Class CohesionClass Cohesion
4-4-22
Foundation DomainFoundation Domain• Classes used in different applications Classes used in different applications
from different industries on different from different industries on different computer architectures computer architectures
• Classes of highest reusabilityClasses of highest reusability
• A foundation class may be built upon A foundation class may be built upon other foundation classesother foundation classes
• Fundamental Classes - primitive typesFundamental Classes - primitive types
• Structural Classes - implementation of Structural Classes - implementation of data structuresdata structures
• Semantic Classes - used conventionally Semantic Classes - used conventionally
4-4-33
Architecture DomainArchitecture Domain
• Usable in different applications from Usable in different applications from different industriesdifferent industries
• Reusability is limited to a single Reusability is limited to a single computer (hardware & software) computer (hardware & software) architecturearchitecture
• Machine-Communication ClassesMachine-Communication Classes
• Database-Manipulation ClassesDatabase-Manipulation Classes
• Human-Interface ClassesHuman-Interface Classes
4-4-44
Business DomainBusiness Domain
• Useful in different applications within a Useful in different applications within a single industrysingle industry
• Reusability may even limited to one Reusability may even limited to one corporationcorporation
• Attribute Classes - properties of thingsAttribute Classes - properties of things
• Role Classes - roles played in businessRole Classes - roles played in business
• Relationship Classes - associations Relationship Classes - associations among thingsamong things
4-4-55
Application DomainApplication Domain• Used only within a single applicationUsed only within a single application
• Lowest reusabilityLowest reusability
• Event-Recognizer ClassesEvent-Recognizer Classes– event daemons–monitor input to check for occurrence of
specific events in the environment
• Event-Manager ClassesEvent-Manager Classes– carry out business policy when an event of a
given type occurs
4-4-66
Domains of Classes and ReusabilityDomains of Classes and Reusability• Application DomainApplication Domain
– event manager classes– event recognizer classes
• Business DomainBusiness Domain– relationship classes– role classes– attribute classes
• Architecture DomainArchitecture Domain– machine communication classes– database manipulation classes– human interface classes
• Foundation DomainFoundation Domain– semantic classes– structural classes– fundamental classes
Low Reusability
Medium Reusability
High Reusability
4-4-77
EncumbranceEncumbrance
• Quantitative Measure of Class SophistiQuantitative Measure of Class Sophisticationcation
• Definition of Encumbrance in Object-OrDefinition of Encumbrance in Object-Oriented Systemsiented Systems
• Use of EncumbranceUse of Encumbrance
• Law of DemeterLaw of Demeter
4-4-88
Class ReferenceClass Reference• Direct Class-Reference Set - Direct Class-Reference Set - the set of classes the set of classes
referred directly by a class (class C refer directly to D if:)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 Indirect Class-Reference Set - union of direct class-reference setsclass-reference sets
4-4-99
Definition of EncumbranceDefinition of Encumbrance• Measures the total ancillary machinery of a Measures the total ancillary machinery of a
classclass– 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 EncumbranceDirect Encumbrance– size of its direct class-reference set
• Indirect EncumbranceIndirect Encumbrance– size of its indirect class-reference set
• Used to indicate class couplingUsed to indicate class coupling
4-4-1010
Use of EncumbranceUse of Encumbrance• Measure of class sophisticationMeasure of class sophistication
• Higher domains have higher Higher domains have higher encumbranceencumbrance
• Unexpected encumbrance may indicate Unexpected encumbrance may indicate a fault in class designa fault in class design– low domain with high encumbrance =>
may have a problem with class cohesion– high domain with low encumbrance =>
lack of reusability
4-4-1111
Law of DemeterLaw of Demeter• Guiding principle for limiting direct Guiding principle for limiting direct
encumbrance of a classencumbrance of a class
• Limitation of message receivers: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 onlycurrent class only• current class plus inherited classescurrent class plus inherited classes
– an object created by a method– an object referred to by a global variable
4-4-1212
Class CohesionClass Cohesion• Measure of interrelationship of attributes Measure of interrelationship of attributes
and operations located in the external and operations located in the external interface of a classinterface of a class
• Observe from outside instead of inside of Observe from outside instead of inside of the classthe class
• Three major cohesion problemsThree major cohesion problems–mixed instance–mixed domain –mixed role
• A class may have more than one cohesion A class may have more than one cohesion problemproblem
4-4-1313
Mixed-Instance CohesionMixed-Instance Cohesion
• A class has some features (attributes A class has some features (attributes or operations) that are undefined for or operations) that are undefined for some objects of the classsome objects of the class
• Design problem of type definitionDesign problem of type definition
• Usually involve redesign of the Usually involve redesign of the inheritance hierarchyinheritance hierarchy
4-4-1414
Mixed-Domain CohesionMixed-Domain Cohesion• A class contains an element that A class contains an element that
directly encumbers the class with an directly encumbers the class with an extrinsic class of a different domainextrinsic class of a different domain
• Class B is Class B is extrinsicextrinsic to A if A can be to A if A can be fully defined with no notion of Bfully defined with no notion of B
• Class B is Class B is intrinsicintrinsic to A if B captures to A if B captures some characteristic inherent to Asome characteristic inherent to A
• Always include classes from lower Always include classes from lower domains because of intrinsic domains because of intrinsic properties of the classproperties of the class
4-4-1515
Mixed-Role CohesionMixed-Role Cohesion
• A class contains an element that A class contains an element that directly encumbers the class with an directly encumbers the class with an extrinsic class of the same domainextrinsic class of the same domain
• Depend on the basic definition Depend on the basic definition (original representation) of the class(original representation) of the class
• Least serious cohesion problemLeast serious cohesion problem
• may reduce reusabilitymay reduce reusability