Systems Analysis and Design Allen Dennis and Barbara Haley Text .._8_

Document Sample
Systems Analysis and Design Allen Dennis and Barbara Haley Text .._8_ Powered By Docstoc
					             Chapter 10
      Class and Method Design



Slide 1
 REVISITING THE BASIC
 CHARACTERISTICS OF
 OBJECT-ORIENTATION




Slide 2
Levels of Abstraction



           Package




 Slide 3
Elements
 Classes
 Objects
 Attributes
 States
 Methods
 Messages
 Slide 4
Encapsulation
 Hiding the content of the object
 from outside view
 Communication only through
 object’s methods
 Key to reusability



 Slide 5
Polymorphism
 Same message triggers different
 methods in different objects
 Dynamic binding means specific method
 is selected at run time
 Implementation of dynamic binding is
 language specific
 Need to be very careful about run time
 errors
 Need to ensure semantic consistency
 Slide 6
Inheritance
 Single inheritance -- one parent
 class
 Multiple inheritance -- multiple
 parent classes
 Redefinition and inheritance conflict
 Most inheritance conflicts are due to
 poor classification

 Slide 7
Rumbaugh’s Rules

           Query operations should not be redefined


           Methods that redefine inherited ones should only restrict
           the semantics of the inherited ones


           The underlying semantics of the inherited method should
           never be changed


           The signature (argument list) of the inherited method should
           never be changed



 Slide 8
Additional Inheritance
Conflicts
      Two inherited attributes or
      methods have same name and
      semantics
      Two inherited attributes or
      methods have different name, but
      same semantics
      Two inherited attributes or
      methods have same name and
      different semantics
 Slide 9
Inheritance Conflicts with
Multiple Inheritance




 Slide 10
Design Criteria




Slide 11
Coupling
 Indicates the interdependence
 or interrelationships of the
 modules
 Interaction coupling
      Relationships with methods and objects
      through message passage

 Inheritance coupling
      How tightly coupled are the classes in the
      inheritance hierarchy?
 Slide 12
Interaction Coupling




 Slide 13
Cohesion
 Determines how single-minded
 a module (class, object, or
 method) is within a system
 Method Cohesion
      Methods should do one and only one thing

 Class Cohesion
      Level of cohesion between the attributes and
      methods of a class

 Slide 14
Types of Method Cohesion




 Slide 15
Ideal Class Cohesion
 Contain multiple methods that
 are visible outside the class
 Have methods that refer to
 attributes or other methods
 defined with the class or its
 superclass
 Not have any control-flow
 coupling between its methods
 Slide 16
Types of Class Cohesion




 Slide 17
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 required
 Generalizes the idea of cohesion
 and coupling
 Slide 18
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.
 Slide 19
Types of Connascence




 Slide 20
     Object Design Activities

1.    Adding Specification
2.    Identifying opportunities for reuse
3.    Restructuring the design
4.    Optimizing the design
5.    Mapping problem classes to Implementation
      Languages
     Slide 21
1. Additional Specification
 Ensure the classes are both
 necessary and sufficient for the
 problem
 Finalize the visibility of the
 attributes and methods of each
 class
 Determine the signature of every
 method of each class
 Define constraints to be preserved
 by objects
 Slide 22
2. Identifying Opportunities
for Reuse
 Analysis patterns
    Problem domain representations
 Design patterns
    Grouping of collaborating classes that provide a
    solution to a commonly occurring problem
 Frameworks
    Set of implemented classes that can be used as a basis
    for implementing an application. E.g: CORBA, DCOM
 Libraries
    Set of class libraries
 Components
    Self-contained, encapsulated piece of software that
    can be plugged-in
 Slide 23
Sample Design Pattern
(Forwarder-Receiver Pattern)




 Slide 24
3. Restructuring the
Design
 Factoring
      Separate aspects of a method or class
      into a new method or class
 Normalization
      Identifies classes missing from the
      design
 Challenge inheritance relationships
 to ensure they only support a
 generalization/specialization
 semantics
 Slide 25
4. Optimizing the Design
 Review access paths between
 objects
 Review each attribute of each
 class
 Review fan-out of each method
 Examine execution order of
 statements
 Create derived activities
 Slide 26
5. Map Problem Domain Classes
to Implementation Languages

 Single-Inheritance Language
      Convert relationships to
      association relationships
      Flatten inheritance hierarchy by
      copying attributes and methods of
      additional superclass(es)



 Slide 27
Implement in Object-Based
Language
 Factor out all uses of
 inheritance from the problem
 domain class design




 Slide 28
Implement in a Traditional
Language
 Stay away from traditional languages to
 implement O-O design
 But if necessary, factor out all uses of
   Polymorphism
   Dynamic binding
   Encapsulation
   Information hiding


 Slide 29
Constraints and Contracts




Slide 30
Types of Constraints
 Pre-Conditions
      A constraint to be met to allow a
      method to execute
 Post-condition
      A constraint to be met after a method
      executes
 Invariants
      Constraints that must be true for all
      instances of a class

 Slide 31
Invariants




 Slide 32
Elements of a Contract




 Slide 33
Method Specification




Slide 34
Method Specification
 General information
 Events
 Message passing
 Algorithm specification
      Structured English
      Pseudocode
      UML activity diagram
 Slide 35
Applying the Concepts at CD
Selections




Slide 36
Revised CD Selections Class
Diagram




 Slide 37
Back of CD CRC Card




 Slide 38
Get Review Method Contract




 Slide 39
Revised Package Diagram




 Slide 40

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:7
posted:6/29/2012
language:
pages:40