slide 1 chapter 10 class and method design. slide 2 revisiting the basic characteristics of...
Post on 21-Dec-2015
224 views
TRANSCRIPT
![Page 1: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/1.jpg)
Slide 1
Chapter 10Class and Method Design
![Page 2: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/2.jpg)
Slide 2
REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION
![Page 3: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/3.jpg)
Slide 3
Levels of Abstraction
Package
![Page 4: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/4.jpg)
Slide 4
Elements
ClassesObjectsAttributesStatesMethodsMessages
![Page 5: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/5.jpg)
Slide 5
Encapsulation
Hiding the content of the object from outside viewCommunication only through object’s methodsKey to reusability
![Page 6: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/6.jpg)
Slide 6
Polymorphism
Same message triggers different methods in different objectsDynamic binding means specific method is selected at run timeImplementation of dynamic binding is language specificNeed to be very careful about run time errorsNeed to ensure semantic consistency
![Page 7: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/7.jpg)
Slide 7
Inheritance
Single inheritance -- one parent classMultiple inheritance -- multiple parent classesRedefinition and inheritance conflictMost inheritance conflicts are due to poor classification
![Page 8: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/8.jpg)
Slide 8
Rumbaugh’s Rules
Query operations should not be redefined
Methods that redefine inherited ones should only restrictthe semantics of the inherited ones
The underlying semantics of the inherited method should never be changed
The signature (argument list) of the inherited method shouldnever be changed
![Page 9: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/9.jpg)
Slide 9
Additional Inheritance Conflicts
Two inherited attributes or methods have same name and semanticsTwo inherited attributes or methods have different name, but same semanticsTwo inherited attributes or methods have same name and different semantics
![Page 10: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/10.jpg)
Slide 10
Inheritance Conflicts with Multiple Inheritance
![Page 11: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/11.jpg)
Slide 11
Design Criteria
![Page 12: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/12.jpg)
Slide 12
Coupling
Indicates the interdependence or interrelationships of the modulesInteraction coupling
Relationships with methods and objects through message passage
Inheritance couplingHow tightly coupled are the classes in the inheritance hierarchy?
![Page 13: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/13.jpg)
Slide 13
Interaction Coupling
![Page 14: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/14.jpg)
Cohesion
Slide 14
Determines how single-minded a module (class, object, or method) is within a systemMethod Cohesion
Methods should do one and only one thing
Class CohesionLevel of cohesion between the attributes and methods of a class
![Page 15: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/15.jpg)
Slide 15
Types of Method Cohesion
![Page 16: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/16.jpg)
Slide 16
Ideal Class Cohesion
Contain multiple methods that are visible outside the classHave methods that refer to attributes or other methods defined with the class or its superclassNot have any control-flow coupling between its methods
![Page 17: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/17.jpg)
Slide 17
Types of Class Cohesion
![Page 18: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/18.jpg)
Slide 18
Connascence
Two modules (classes or methods) are so intertwined, that if you make a change in one, it is likely that a change in the other will be requiredGeneralizes the idea of cohesion and coupling
![Page 19: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/19.jpg)
Slide 19
Connascence and Encapsulation Levels
Minimize overall connascence by eliminating any unnecessary connascence throughout the system,Minimize connascence across any encapsulation boundaries, such as method boundaries and class boundaries, Maximize connascence within any encapsulation boundary.
![Page 20: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/20.jpg)
Slide 20
Types of Connascence
![Page 21: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/21.jpg)
Slide 21
Object Design Activities
1. Adding Specification2. Identifying opportunities for reuse3. Restructuring the design4. Optimizing the design5. Mapping problem classes to Implementation
Languages
![Page 22: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/22.jpg)
Slide 22
1. Additional SpecificationEnsure the classes are both necessary and sufficient for the problemFinalize the visibility of the attributes and methods of each classDetermine the signature of every method of each classDefine constraints to be preserved by objects
![Page 23: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/23.jpg)
Slide 23
2. Identifying Opportunities for Reuse
Analysis patternsProblem domain representations
Design patternsGrouping of collaborating classes that provide a solution to a commonly occurring problem
FrameworksSet of implemented classes that can be used as a basis for implementing an application. E.g: CORBA, DCOM
LibrariesSet of class libraries
ComponentsSelf-contained, encapsulated piece of software that can be plugged-in
![Page 24: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/24.jpg)
Slide 24
Sample Design Pattern(Forwarder-Receiver Pattern)
![Page 25: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/25.jpg)
Slide 25
3. Restructuring the Design
Factoring Separate aspects of a method or class into a new method or class
NormalizationIdentifies classes missing from the design
Challenge inheritance relationships to ensure they only support a generalization/specialization semantics
![Page 26: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/26.jpg)
Slide 26
4. Optimizing the Design
Review access paths between objectsReview each attribute of each classReview fan-out of each methodExamine execution order of statementsCreate derived activities
![Page 27: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/27.jpg)
Slide 27
5. Map Problem Domain Classes to Implementation Languages
Single-Inheritance LanguageConvert relationships to association relationshipsFlatten inheritance hierarchy by copying attributes and methods of additional superclass(es)
![Page 28: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/28.jpg)
Slide 28
Implement in Object-Based Language
Factor out all uses of inheritance from the problem domain class design
![Page 29: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/29.jpg)
Slide 29
Implement in a Traditional Language
Stay away from traditional languages to implement O-O designBut if necessary, factor out all uses of
PolymorphismDynamic bindingEncapsulationInformation hiding
![Page 30: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/30.jpg)
Slide 30
Constraints and Contracts
![Page 31: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/31.jpg)
Slide 31
Types of Constraints
Pre-ConditionsA constraint to be met to allow a method to execute
Post-conditionA constraint to be met after a method executes
InvariantsConstraints that must be true for all instances of a class
![Page 32: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/32.jpg)
Slide 32
Invariants
![Page 33: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/33.jpg)
Slide 33
Elements of a Contract
![Page 34: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/34.jpg)
Slide 34
Method Specification
![Page 35: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/35.jpg)
Slide 35
Method Specification
General informationEventsMessage passingAlgorithm specification
Structured EnglishPseudocodeUML activity diagram
![Page 36: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/36.jpg)
Slide 36
Applying the Concepts at CD Selections
![Page 37: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/37.jpg)
Slide 37
Revised CD Selections Class Diagram
![Page 38: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/38.jpg)
Slide 38
Back of CD CRC Card
![Page 39: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/39.jpg)
Slide 39
Get Review Method Contract
![Page 40: Slide 1 Chapter 10 Class and Method Design. Slide 2 REVISITING THE BASIC CHARACTERISTICS OF OBJECT-ORIENTATION](https://reader035.vdocuments.net/reader035/viewer/2022062221/56649d6a5503460f94a48071/html5/thumbnails/40.jpg)
Slide 40
Revised Package Diagram