A Practical Definition of Design
A Brief Introduction to Object-Oriented Programming
2 Designing Classes with a Single Responsibility
Deciding What Belongs in a Class
Organizing Code to Allow for Easy Changes
Creating Classes That Have a Single Responsibility
An Example Application: Bicycles and Gears
Why Single Responsibility Matters
Determining If a Class Has a Single Responsibility
Determining When to Make Design Decisions
Writing Code That Embraces Change
Enforce Single Responsibility Everywhere
Coupling Between Objects (CBO)
Remove Argument-Order Dependencies
4 Creating Flexible Interfaces
Responsibilities, Dependencies, and Interfaces
An Example Application: Bicycle Touring Company
Asking for “What” Instead of Telling “How”
Using Messages to Discover Objects
Creating a Message-Based Application
Writing Code That Puts Its Best (Inter)Face Forward
Honor the Public Interfaces of Others
Exercise Caution When Depending on Private Interfaces
5 Reducing Costs with Duck Typing
Writing Code That Relies on Ducks
Conquering a Fear of Duck Typing
Subverting Duck Types with Static Typing
6 Acquiring Behavior Through Inheritance
Understanding Classical Inheritance
Recognizing Where to Use Inheritance
Starting with a Concrete Class
Drawing Inheritance Relationships
Creating an Abstract Superclass
Separating Abstract from Concrete
Using the Template Method Pattern
Implementing Every Template Method
Managing Coupling Between Superclasses and Subclasses
Decoupling Subclasses Using Hook Messages
7 Sharing Role Behavior with Modules
Removing Unnecessary Dependencies
Use the Template Method Pattern
8 Combining Objects with Composition
Making the Parts Object More Like an Array
Deciding Between Inheritance and Composition
Accepting the Consequences of Inheritance
Accepting the Consequences of Composition
9 Designing Cost-Effective Tests
Isolating the Object Under Test
Injecting Dependencies Using Classes
Injecting Dependencies as Roles
Ignoring Private Methods During Tests
Removing Private Methods from the Class Under Test
Choosing to Test a Private Method
Using Role Tests to Validate Doubles
Specifying the Inherited Interface
18.118.24.106