Object-Oriented Design Heuristics

Book description

Upon completion of an object-oriented design, you are faced with a troubling question: "Is it good, bad, or somewhere in between?" Seasoned experts often answer this question by subjecting the design to a subconscious list of guidelines based on their years of experience. Experienced developer Arthur J. Riel has captured this elusive, subconscious list, and in doing so, has provided a set of metrics that help determine the quality of object-oriented models.

Object-Oriented Design Heuristics offers insight into object-oriented design improvement. The more than sixty guidelines presented in this book are language-independent and allow you to rate the integrity of a software design. The heuristics are not written as hard and fast rules; they are meant to serve as warning mechanisms which allow the flexibility of ignoring the heuristic as necessary. This tutorial-based approach, born out of the author's extensive experience developing software, teaching thousands of students, and critiquing designs in a variety of domains, allows you to apply the guidelines in a personalized manner.

The heuristics cover important topics ranging from classes and objects (with emphasis on their relationships including association, uses, containment, and both single and multiple inheritance) to physical object-oriented design. You will gain an understanding of the synergy that exists between design heuristics and the popular concept of design patterns; heuristics can highlight a problem in one facet of a design while patterns can provide the solution.

Programmers of all levels will find value in this book. The newcomer will discover a fast track to understanding the concepts of object-oriented programming. At the same time, experienced programmers seeking to strengthen their object-oriented development efforts will appreciate the insightful analysis. In short, with Object-Oriented Design Heuristics as your guide, you have the tools to become a better software developer.

020163385XB04062001

Table of contents

  1. Copyright
    1. Dedication
  2. Preface
  3. Acknowledgements
  4. 1. The Motivation for Object-Oriented Programming
    1. 1.1. Revolutionists, Evolutionists, and the Object-Oriented Paradigm
    2. 1.2. Accidental Versus Essential Complexity à la Frederick Brooks
    3. 1.3. The Waterfall Model
    4. 1.4. The Iterative Model
    5. 1.5. Same- Versus Different-Language Prototyping
    6. 1.6. Software Reusability
    7. 1.7. Corporate Hierarchies of Good Designers
    8. Glossary of Terms
  5. 2. Classes and Objects: The Building Blocks of the Object-Oriented Paradigm
    1. 2.1. Introduction to Classes and Objects
      1. Heuristic 2.1
    2. 2.2. Messages and Methods
      1. Heuristic 2.2
      2. Heuristic 2.3
      3. Heuristic 2.4
      4. Heuristic 2.5
      5. Heuristic 2.6
    3. 2.3. Class Coupling and Cohesion
      1. Heuristic 2.7
      2. Heuristic 2.8
      3. Heuristic 2.9
      4. Heuristic 2.10
    4. 2.4. Dynamic Semantics
    5. 2.5. Abstract Classes
    6. 2.6. Roles Versus Classes
      1. Heuristic 2.11
    7. Glossary of Terms
    8. Summary of Heuristics
  6. 3. Topologies of Action-Oriented Versus Object-Oriented Applications
    1. 3.1. Differences in Application Topologies
    2. 3.2. When the Action-Oriented Paradigm Goes Right
    3. 3.3. The God Class Problem (Behavioral Form)
      1. Heuristic 3.1
      2. Heuristic 3.2
      3. Heuristic 3.3
      4. Heuristic 3.4
      5. Heuristic 3.5
    4. 3.4. Another Example of Poor System Intelligence Distribution
      1. Heuristic 3.6
    5. 3.5. The God Class Problem (Data Form)
    6. 3.6. The Proliferation of Classes Problem
      1. Heuristic 3.7
      2. Heuristic 3.8
      3. Heuristic 3.9
    7. 3.7. The Role of Agent Classes
      1. Heuristic 3.10
    8. 3.8. Examining the Use of Separate Entity and Controller Classes
    9. Glossary of Terms
    10. Summary of Heuristics
  7. 4. The Relationships Between Classes and Objects
    1. 4.1. Introduction to Class and Object Relationships
    2. 4.2. The Uses Relationship
    3. 4.3. Six Different Ways to Implement the Uses Relationship
    4. 4.4. Heuristics for the Uses Relationship
      1. Heuristic 4.1
    5. 4.5. Refining the Amount of Collaboration Between Two Classes
      1. Heuristic 4.2
      2. Heuristic 4.3
      3. Heuristic 4.4
    6. 4.6. The Containment Relationship
      1. Heuristic 4.5
      2. Heuristic 4.6
      3. Heuristic 4.7
      4. Heuristic 4.8
    7. 4.7. Semantic Constraints Between Classes
      1. Heuristic 4.9
      2. Heuristic 4.10
      3. Heuristic 4.11
      4. Heuristic 4.12
    8. 4.8. Attributes Versus Contained Classes
    9. 4.9. More Containment Heuristics
      1. Heuristic 4.13
      2. Heuristics 4.14
    10. 4.10. A Relationship Between Uses and Containment?
    11. 4.11. Containment by Value Versus Containment by Reference
    12. Glossary of Terms
    13. Summary of Heuristics
  8. 5. The Inheritance Relationship
    1. 5.1. Introduction to the Inheritance Relationship
    2. 5.2. Overriding Base Class Methods in Derived Classes
      1. Heuristic 5.1
      2. Heuristic 5.2
    3. 5.3. The Use of the Protected Section of a Base Class
      1. Heuristic 5.3
    4. 5.4. The Width and Depth of Inheritance Hierarchies
      1. Heuristic 5.4
      2. Heuristic 5.5
    5. 5.5. Private, Protected, and Public Inheritance à la C+ +
    6. 5.6. A Real-World Example of Specialization
    7. 5.7. Heuristics That Trade Off Design Complexity and Flexibility
      1. Heuristic 5.6
      2. Heuristic 5.7
    8. 5.8. A Real-World Example of Generalization
      1. Heuristic 5.8
    9. 5.9. The Mechanism of Polymorphism
      1. Heuristic 5.9
      2. Heuristic 5.10
      3. Heuristic 5.11
      4. Heuristic 5.12
    10. 5.10. A Problem with the Use of Inheritance as a Reusability Mechanism
    11. 5.11. An Inheritance Solution to an Interrupt-Driven Architecture
    12. 5.12. Inheritance Hierarchies Versus Attributes
      1. Heuristic 5.13
    13. 5.13. The Confusion of the Need for Inheritance Versus an Object's Dynamic Semantics
      1. Heuristic 5.14
    14. 5.14. Using Inheritance to Hide the Representation of a Class
    15. 5.15. Mistaking Objects for Derived Classes
      1. Heuristic 5.15
    16. 5.16. Mistaking Object Generalization for the Need to Build Classes at Runtime
      1. Heuristic 5.16
    17. 5.17. The Attempt to NOP a Base Class Method in Its Derived Class(es)
      1. Heuristic 5.17
    18. 5.18. The Implementation of Optional Parts of Objects
      1. Heuristic 5.18
    19. 5.19. A Problem with No Optimal Solution
    20. 5.20. Reusing Components Versus Reusing Frameworks
      1. Heuristic 5.19
    21. Glossary
    22. Summary of Heuristics
  9. 6. Multiple Inheritance
    1. 6.1. Introduction to Multiple Inheritance
      1. Heuristic 6.1
    2. 6.2. The Common Misuse of Multiple Inheritance
      1. Heuristic 6.2
      2. Heuristic 6.3
    3. 6.3. A Valid Use of Multiple Inheritance
    4. 6.4. Accidental Complexity In Languages That Do Not Support Multiple Inheritance
    5. 6.5. Frameworks That Incorporate Multiple Inheritance
    6. 6.6. The Use of Multiple Inheritance in the Design of Mixins
    7. 6.7. DAG Multiple Inheritance
    8. 6.8. Accidental DAG Multiple Inheritance via Poor Implementation of Optional Containment
    9. Glossary
    10. Heuristics Summary
  10. 7. The Association Relationship
    1. 7.1. Introduction to Association
    2. 7.2. Associations Implemented Through a Referential Attribute
    3. 7.3. Association Implemented Through a Third-Party Class
    4. 7.4. Deciding Between a Containment and an Association Relationship
      1. Heuristic 7.1
    5. Glossary
    6. Heuristics Summary
  11. 8. Class-Specific Data and Behavior
    1. 8.1. Introduction to Class-Specific Versus Object-Specific Data and Behavior
      1. Heuristic 8.1
    2. 8.2. Using Metaclasses to Capture Class-Specific Data and Behavior
    3. 8.3. Using Language-Level Keywords to Implement Class-Versus Object-Specific Data and Behavior
    4. 8.4. Metaclasses à la C++
    5. 8.5. A Useful Abstract Class That Is Not a Base Class?
    6. Glossary
    7. Heuristics Summary
  12. 9. Physical Object-Oriented Design
    1. 9.1. The Role of Logical and Physical Object-Oriented Design
      1. Heuristic 9.1
    2. 9.2. The Construction of Object-Oriented Wrappers
    3. 9.3. Persistence in an Object-Oriented System
    4. 9.4. Memory Management Issues in an Object-Oriented Application
    5. 9.5. Minimal Public Interfaces for Reusable Components
      1. A Minimal Public Interface for All Reusable Classes
        1. Constructor.
        2. Destructor.
        3. Copying Objects.
        4. Assigning Objects.
        5. Equality Testing.
        6. Print.
        7. Parse.
        8. Self-Test.
    6. 9.6. Implementing Safe Shallow Copies
      1. Heuristic 9.2
    7. 9.7. Concurrent Object-Oriented Programming
    8. 9.8. Implementing Object-Oriented Designs in Nonobject-Oriented Languages
      1. Overloaded Functions.
      2. Class/Object.
      3. Data Hiding.
      4. Inheritance.
      5. Polymorphism.
    9. Glossary
    10. Summary of Heuristics
  13. 10. The Relationship Between Heuristics and Patterns
    1. 10.1. Heuristics Versus Patterns
      1. The Broadcast Pattern
        1. Source Pattern.
        2. Motivating Heuristic.
        3. Rationale.
        4. Target Pattern.
    2. 10.2. Transitivity Among Design Transformation Patterns
      1. The Interrupt Pattern
        1. Source Pattern.
        2. Motivating Heuristic
        3. Rationale.
        4. Target Pattern.
      2. The Interrupt-Polling Pattern
        1. Source Pattern.
        2. Motivating Heuristic.
        3. Rationale.
        4. Target Pattern.
    3. 10.3. The Reflexive Property of Design Transformation Patterns
      1. The Generalization Pattern
        1. Source Pattern.
        2. Motivating Heuristic.
        3. Rationale.
        4. Target Pattern.
      2. The Specialization Pattern
        1. Source Pattern.
        2. Motivating Heuristic.
        3. Rationale.
        4. Target Pattern.
    4. 10.4. Other Design Transformation Patterns
      1. The Inverted Inheritance Pattern
        1. Source Pattern.
        2. Motivating Heuristic.
        3. Rationale.
        4. Target Pattern.
      2. The Lexical Scope Pattern
        1. Source Pattern.
        2. Motivational Heuristic.
        3. Rationale.
        4. Target Pattern.
      3. The One-Instance Pattern
        1. Source Pattern.
        2. Motivational Heuristic.
        3. Rationale.
        4. Target Pattern.
      4. The Data-Hiding Pattern
        1. Source Pattern.
        2. Motivating Heuristic.
        3. Rationale.
        4. Target Pattern.
    5. 10.5. Future Research
  14. 11. The Use of Heuristics in Object-Oriented Design
    1. 11.1. The ATM Problem
      1. The ATM System Requirement Specification
    2. 11.2. Choosing a Methodology
    3. 11.3. A First Attempt at Producing an Object Model for the ATM
    4. 11.4. Adding Behavior to Our Object Model
    5. 11.5. Explicit Case Analysis Due to Accidental Complexity
    6. 11.6. Messaging Objects in Different Address Spaces
    7. 11.7. The Processing of the Transaction
    8. 11.8. Returning to the Domain of the ATM
    9. 11.9. Other Miscellaneous Issues
    10. 11.10. Conclusion
  15. A. Heuristics Summary
    1. Chapter 2 Classes and Objects: The Building Blocks of the Object-Oriented Paradigm
    2. Chapter 3 Topologies of Action-Oriented Versus Object-Oriented Applications
    3. Chapter 4 The Relationships Between Classes and Objects
    4. Chapter 5 The Inheritance Relationship
    5. Chapter 6 Multiple Inheritance
    6. Chapter 7 The Association Relationship
    7. Chapter 8 Class-Specific Data and Behavior
    8. Chapter 9 Physical Object-Oriented Design
  16. B. The Prevention of Memory Leakage
    1. Leak #1
    2. Example Code for Leak #1
    3. Leak #2
    4. Example Code for Leak #2
    5. Leak #3
    6. Example Code for Leak #3
    7. Leak #4
    8. Example Code for Leak #4
    9. Leak #5
    10. Example Code for Leak #5
    11. Leak #6
    12. Example Code for Leak #6
    13. Leak #7
    14. Returning a Reference to a Stack Object
    15. Returning an Internal Static Object Reference
    16. Returning a Memory Leaking Dynamically Allocated Object
    17. Correct Method for Leak #7
    18. Leak #8
    19. Code Example for Memory Leakage #8
  17. C. Selected C++ Examples
    1. Selected C++ Example #2
    2. Selected C++ Example #4
    3. Selected C++ Example #5
    4. Selected C++ Example #9
    5. Selected C++ Example #10
    6. Selected C++ Example #15
    7. Selected C++ Example #17
    8. Selected C++ Example #18
    9. Selected C++ Example #19
    10. Selected C++ Example #20
    11. Selected C++ Example #21
    12. The ATM Side of the Application
    13. The Atm.hpp File
    14. The Atm.cpp File
    15. The Bank Side of the Application
    16. The Bank.hpp File
    17. The Bank.cpp File
    18. The Common Classes
    19. The Trans.hpp File
    20. The Trans.cpp File
    21. The Network.hpp File
    22. The Network.cpp File
  18. Bibliography
  19. Other Books Used for Reference in This Text

Product information

  • Title: Object-Oriented Design Heuristics
  • Author(s): Arthur J. Riel
  • Release date: April 1996
  • Publisher(s): Addison-Wesley Professional
  • ISBN: 9780201633856