Chapter 1: Building Better Programs with Patterns
Separate Out the Things That Change from Those That Stay the Same
Program to an Interface, Not an Implementation
Prefer Composition over Inheritance
Chapter 2: Getting Started with Ruby
But Sometimes There Is No Object
Getting at the Instance Variables
Inheritance, Subclasses, and Superclasses
Managing Separate Source Files
Chapter 3: Varying the Algorithm with the Template Method
Keeping Up with What Life Throws at You
Separate the Things That Stay the Same
Discovering the Template Method Pattern
But Where Are All the Declarations?
Types, Safety, and Flexibility
Using and Abusing the Template Method Pattern
Chapter 4: Replacing the Algorithm with the Strategy
Delegate, Delegate, and Delegate Again
Sharing Data between the Context and the Strategy
Using and Abusing the Strategy Pattern
The Strategy Pattern in the Wild
Chapter 5: Keeping Up with the Times with the Observer
Factoring Out the Observable Support
Variations on the Observer Pattern
Using and Abusing the Observer Pattern
Chapter 6: Assembling the Whole from the Parts with the Composite
Sprucing Up the Composite with Operators
Using and Abusing the Composite Pattern
Chapter 7: Reaching into a Collection with the Iterator
Internal Iterators versus External Iterators
Using and Abusing the Iterator Pattern
Chapter 8: Getting Things Done with Commands
Using and Abusing the Command Pattern
The Command Pattern in the Wild
Chapter 9: Filling in the Gaps with the Adapter
Using and Abusing the Adapter Pattern
Chapter 10: Getting in Front of Your Object with a Proxy
Eliminating That Proxy Drudgery
Chapter 11: Improving Your Objects with a Decorator
Decorators: The Cure for Ugly Code
Dynamic Alternatives to the Decorator Pattern
Using and Abusing the Decorator Pattern
Chapter 12: Making Sure There Is Only One with the Singleton
A First Try at a Ruby Singleton
Alternatives to the Classic Singleton
Global Variables as Singletons
A Safety Harness or a Straitjacket?
Using and Abusing the Singleton Pattern
They Are Really Just Global Variables, Right?
Just How Many of These Singletons Do You Have?
Singletons on a Need-to-Know Basis
Chapter 13: Picking the Right Class with a Factory
A Different Kind of Duck Typing
The Template Method Strikes Again
Bad News: Your Program Hits the Big Time
Classes Are Just Objects (Again)
Using and Abusing the Factory Patterns
Chapter 14: Easier Object Construction with the Builder
Builders Can Ensure Sane Objects
Better Builders with Magic Methods
Using and Abusing the Builder Pattern
Chapter 15: Assembling Your System with the Interpreter
The Right Language for the Job
More Complex Searches with Not, And, and Or
Let XML or YAML Do the Parsing?
Using and Abusing the Interpreter Pattern
Chapter 16: Opening Up Your System with Domain-Specific Languages
The Domain of Specific Languages
It’s a Data File—No, It’s a Program!
Using and Abusing Internal DSLs
Chapter 17: Creating Custom Objects with Meta-programming
Custom-Tailored Objects, Method by Method
Custom Objects, Module by Module
Conjuring Up Brand-New Methods
Using and Abusing Meta-programming
Chapter 18: Convention Over Configuration
A Good User Interface—for Developers
Taking Stock of the Message Gateway
Using and Abusing the Convention Over Configuration Pattern
Convention Over Configuration in the Wild
Appendix A: Getting Hold of Ruby
Installing Ruby on Microsoft Windows
3.147.81.214