Object-Oriented Design Choices  book cover
1st Edition

Object-Oriented Design Choices

  • Available for pre-order. Item will ship after January 19, 2021
ISBN 9780367820183
January 19, 2021 Forthcoming by Chapman and Hall/CRC
288 Pages 14 B/W Illustrations

SAVE ~ $13.99
was $69.95
USD $55.96

Prices & shipping based on shipping country


Book Description

Do modern programming languages, IDEs and libraries make coding easy?  Maybe, but coding is not design.  Large-scale or expensive apps clearly require evaluation of design choices.  Still, software design directly impacts code reuse and longevity even for small-scale apps with limited overhead.  This text evaluates and contrast common object-oriented designs.

A given problem may have many solutions. A developer may employ different design techniques – composition, inheritance, dependency injection, delegation, etc. – to solve a particular problem.  A skilled developer can determine the costs and benefits of different design responses, even amid competing concerns. A responsible developer documents design choices as a contract with the client, delineating external and internal responsibilities. To promote effective software design, this book examines contractual, object-oriented designs for immediate and sustained use as well as code reuse.  The intent of identifying design variants is to recognize and manage conflicting goals such as: short versus long-term utility, stability versus flexibility, storage versus computation.  Many examples are given to evaluate and contrast different solutions, and to compare C# and C++ effects.  No one has a crystal ball. However, deliberate design promotes software longevity. With the prominence of legacy OO code, a clear understanding of different object-oriented designs is essential.   

Design questions abound. Is code reuse better with inheritance or composition?  Should composition rely on complete encapsulation?  Design choices impact flexibility, efficiency, stability, longevity and reuse.  Yet, compilers do not enforce design and syntax does not necessarily illustrate design.  Through deliberate design, or redesign when refactoring, developers construct sustainable, efficient code. 

Table of Contents


Detailed Book Outline

Section I:  Stable Type Desig

Contractual Design and the Class Construct


Explicit Design and Constraints

Class (Type) Functionality


Accessors and Mutators

Utility and Public Methods


Design as a Contract

Error Handling

Published Assumptions


Programming by Contract Example

Contractual Expectations

OO Design Principle


Design Exercises

Ownership – Abstracted but Tracked

The Abstraction of Memory 

Heap Memory

Ownership of Heap Objects

Array Allocation

Design Intervention

Persistent Data

Class Design  

Memory Reclamation

C++ Explicit Deallocation

Garbage Collection

Reference Counting

Design: Storage vs Computation 

OO Design Principle


Design Exercise


Data Integrity

Data Corruption


Shallow versus Deep Copying

C++ Copying of Internal Heap Memory

Unseen Aliasing

C# Cloning to Avoid Aliasing

Move semantics 

Handle: C++ Smart Pointers





OO Design Principle


Design Exercises


Section II: Strategic Type Coupling


Object-oriented Relationships

Containment (Holds-A)

Composition (Has-A)



Postponed instantiation

Echoing an Interface

Interfaces for Design Consistency

Wrappers and Delegates

Dependency Injection

Constructor Injection

Property (Setter) Injection

Method Injection

Dependency Injection Costs and Benefits

OO Design Principle


Design Exercises



Automate Type Checking 




Subtype polymorphism

Function inlining

Costs and Benefits of Polymorphism 

Dynamic Binding 

whoami() type identification

Keywords for dynamic binding

 Heterogeneous Collections

Virtual Function table 

Abstract Classes

Inheritance designs

OO Design Principle


Design Exercises

Inheritance vs Composition  

Constrained Inheritance

When Only Composition is Viable

When Inheritance Leaks Memory:  C++ destructors

Inconsistent Access: 

C++ accessibility and binding

Code Reuse

Class Design: Has-a or Is-a?

Inheritance with and without Composition

5Software Maintainability

OO Design Principle


Design Exercises


Section III:  Effective Type Reuse

Design Longevity

Software Evolution

Disassembler Example

Virtual Function Table

Type Extraction

Problematic Type Extension

Multiple Inheritance and its Simulation

Design difficulties

Single inheritance with composition

Simulation without inheritance

Class Hierarchies Cross-Products

OO Design Principle


Design Exercises

Operator Overloading

Operators represent functions

Overloading Addition in C++

Client Expectations

Operator Overloading in C#

Operators Overloaded only in C++

Indexing support

I/O via the stream operators

Type conversion

Transparent access

OO Design Principle


Design Exercise


Appendix A:   The Pointer Construct

Pointer definition

Dereferencing pointers

Inappropriate use of pointers

Transient versus persistent memory


The this pointer



Appendix B:   Design Examples

Contractual Design

Ownership:  C++ class memory management




Appendix C:   Comparative Design Examples

Composition versus Inheritance

Design longevity

Operator overloading



View More



Adair Dingle is a professor of computer science and software engineering at Seattle University, Washington, USA. She holds a B.Sc in mathematics from Duke University, Durham, North Carolina, USA; a M.Sc in computer science from Northwestern University, Evanston, Illinois, USA; and a Ph.D in computer science from the University of Texas at Dallas, USA. She is coauthor of the book, C++: Memory First, and her work has been published in numerous refereed journals and conference proceedings. Her research interests include computer game dynamics, efficient memory management for object-oriented programming languages and applications, and patterns as tools for software engineering education.