Practical Object Oriented Design In Ruby

  • 3.8 (6 ratings)
  • 8 Want to read
  • 1 Currently reading
  • 8 Have read

My Reading Lists:

Create a new list

  • 3.8 (6 ratings)
  • 8 Want to read
  • 1 Currently reading
  • 8 Have read

Buy this book

Last edited by Drini
January 23, 2026 | History

Practical Object Oriented Design In Ruby

  • 3.8 (6 ratings)
  • 8 Want to read
  • 1 Currently reading
  • 8 Have read

This edition doesn't have a description yet. Can you add one?

Publish Date
Language
English
Pages
247

Buy this book

Previews available in: English

Edition Availability
Cover of: Practical Object Oriented Design In Ruby
Practical Object Oriented Design In Ruby
2012, Addison-Wesley Professional
in English

Add another edition?

Book Details


Table of Contents

Foreword
Page xv
Introduction
Page xvii
Acknowledgments
Page xxi
About the Author
Page xxiii
1. Object-Oriented Design
Page 1
In Praise of Design
Page 2
The Problem Design Solves
Page 2
Why Change Is Hard
Page 3
A Practical Definition of Design
Page 4
The Tools of Design
Page 4
Design Principles
Page 5
Design Patterns
Page 6
The Act of Design
Page 7
How Design Fails
Page 7
When to Design
Page 8
Judging Design
Page 10
A Brief Introduction to Object-Oriented Programming
Page 11
Procedural Languages
Page 12
Object-Oriented Languages
Page 12
Summary
Page 14
2. Designing Classes with a Single Responsibility
Page 15
Deciding What Belongs in a Class
Page 16
Grouping Methods into Classes
Page 16
Organizing Code to Allow for Easy Changes
Page 16
Creating Classes That Have a Single Responsibility
Page 17
An Example Application: Bicycles and Gears
Page 17
Why Single Responsibility Matters
Page 20
Determining If a Class Has a Single Responsibility
Page 22
Determining When to Make Design Decisions
Page 22
Writing Code That Embraces Change
Page 24
Depend on Behavior, Not Data
Page 24
Enforce Single Responsibility Everywhere
Page 29
Finally, the Real Wheel
Page 33
Summary
Page 34
3. Managing Dependencies
Page 35
Understanding Dependencies
Page 36
Recognizing Dependencies
Page 37
Coupling Between Objects (CBO)
Page 37
Other Dependencies
Page 38
Writing Loosely Coupled Code
Page 39
Inject Dependencies
Page 39
Isolate Dependencies
Page 42
Remove Argument-Order Dependencies
Page 46
Managing Dependency Direction
Page 51
Reversing Dependencies
Page 51
Choosing Dependency Direction
Page 53
Summary
Page 57
4. Creating Flexible Interfaces
Page 59
Understanding Interfaces
Page 59
Defining Interfaces
Page 61
Public Interfaces
Page 62
Private Interfaces
Page 62
Responsibilities, Dependencies, and Interfaces
Page 62
Finding the Public Interface
Page 63
An Example Application: Bicycle Touring Company
Page 63
Constructing an Intention
Page 64
Using Sequence Diagrams
Page 65
Asking for "What" Instead of Telling "How"
Page 69
Seeking Context Independence
Page 71
Trusting Other Objects
Page 73
Using Messages to Discover Objects
Page 74
Creating a Message-Based Application
Page 76
Writing Code That Puts Its Best (Inter)Face Forward
Page 76
Create Explicit Interfaces
Page 76
Honor the Public Interfaces of Others
Page 78
Exercise Caution When Depending on Private Interfaces
Page 79
Minimize Context
Page 79
The Law of Demeter
Page 80
Defining Demeter
Page 80
Consequences of Violations
Page 80
Avoiding Violations
Page 82
Listening to Demeter
Page 82
Summary
Page 83
5. Reducing Costs with Duck Typing
Page 85
Understanding Duck Typing
Page 85
Overlooking the Duck
Page 87
Compounding the Problem
Page 87
Finding the Duck
Page 90
Consequences of Duck Typing
Page 94
Writing Code That Relies on Ducks
Page 95
Recognizing Hidden Ducks
Page 96
Placing Trust in Your Ducks
Page 98
Documenting Duck Types
Page 98
Sharing Code Between Ducks
Page 99
Choosing Your Ducks Wisely
Page 99
Conquering a Fear of Duck Typing
Page 100
Subverting Duck Types with Static Typing
Page 100
Static versus Dynamic Typing
Page 101
Embracing Dynamic Typing
Page 102
Summary
Page 104
6. Acquiring Behavior Through Inheritance
Page 105
Understanding Classical Inheritance
Page 105
Recognizing Where to Use Inheritance
Page 106
Starting with a Concrete Class
Page 106
Embedding Multiple Types
Page 109
Finding the Embedded Types
Page 111
Choosing Inheritance
Page 112
Drawing Inheritance Relationships
Page 114
Misapplying Inheritance
Page 114
Finding the Abstraction
Page 116
Creating an Abstract Superclass
Page 117
Promoting Abstract Behavior
Page 120
Separating Abstract from Concrete
Page 123
Using the Template Method Pattern
Page 125
Implementing Every Template Method
Page 127
Managing Coupling Between Superclasses and Subclasses
Page 129
Understanding Coupling
Page 129
Decoupling Subclasses Using Hook Messages
Page 134
Summary
Page 139
7. Sharing Role Behavior with Modules
Page 141
Understanding Roles
Page 142
Finding Roles
Page 142
Organizing Responsibilities
Page 143
Removing Unnecessary Dependencies
Page 145
Writing the Concrete Code
Page 147
Extracting the Abstraction
Page 150
Looking Up Methods
Page 154
Inheriting Role Behavior
Page 158
Writing Inheritable Code
Page 158
Recognize the Antipatterns
Page 158
Insist on the Abstraction
Page 159
Honor the Contract
Page 159
Use the Template Method Pattern
Page 160
Preemptively Decouple Classes
Page 161
Create Shallow Hierarchies
Page 161
Summary
Page 162
8. Combining Objects with Composition
Page 163
Composing a Bicycle of Parts
Page 164
Updating the Bicycle Class
Page 164
Creating a Parts Hierarchy
Page 165
Composing the Parts Object
Page 168
Creating a Part
Page 169
Making the Parts Object More Like an Array
Page 172
Manufacturing Parts
Page 176
Creating the PartsFactory
Page 177
Leveraging the PartsFactory
Page 178
The Composed Bicycle
Page 180
Deciding Between Inheritance and Composition
Page 184
Accepting the Consequences of Inheritance
Page 184
Accepting the Consequences of Composition
Page 187
Choosing Relationships
Page 188
Summary
Page 190
9. Designing Cost-Effective Tests
Page 191
Intentional Testing
Page 192
Knowing Your Intentions
Page 193
Knowing What to Test
Page 194
Knowing When to Test
Page 197
Knowing How to Test
Page 198
Testing Incoming Messages
Page 200
Deleting Unused Interfaces
Page 202
Proving the Public Interface
Page 203
Isolating the Object Under Test
Page 205
Injecting Dependencies Using Classes
Page 207
Injecting Dependencies as Roles
Page 208
Testing Private Methods
Page 213
Ignoring Private Methods During Tests
Page 213
Removing Private Methods from the Class Under Test
Page 214
Choosing to Test a Private Method
Page 214
Testing Outgoing Messages
Page 215
Ignoring Query Messages
Page 215
Proving Command Messages
Page 216
Testing Duck Types
Page 219
Testing Roles
Page 219
Using Role Tests to Validate Doubles
Page 224
Testing Inherited Code
Page 229
Specifying the Inherited Interface
Page 229
Specifying Subclass Responsibilities
Page 233
Testing Unique Behavior
Page 236
Summary
Page 240
Afterword
Page 241
Index
Page 243

Classifications

Library of Congress
QA76.64.M485 2013, QA76.64 .M485 2013

Edition Identifiers

Open Library
OL26007226M
ISBN 13
9780321721334
LCCN
2012026008
OCLC/WorldCat
773222860

Work Identifiers

Work ID
OL17424491W

Community Reviews (0)

No community reviews have been submitted for this work.

Lists

Download catalog record: RDF / JSON / OPDS | Wikipedia citation