“Design Patterns in Ruby is a great way for programmers from statically typed object-oriented languages to learn how design patterns appear in a more dynamic, flexible language like Ruby.”
PART I: Patterns and Ruby
Chapter 1: Building Better Programs with Patterns
Chapter 2: Getting Started with Ruby
PART II: Patterns in Ruby
Chapter 3: Varying the Algorithm with the Template Method
Chapter 4: Replacing the Algorithm with the Strategy
Chapter 5: Keeping Up with the Times with the Observer
Chapter 6: Assembling the Whole from the Parts with the Composite
Chapter 7: Reaching into a Collection with the Iterator
Chapter 8: Getting Things Done with Commands
Chapter 9: Filling in the Gaps with the Adapter
Chapter 10: Getting in Front of Your Object with a Proxy
Chapter 11: Improving Your Objects with a Decorator
Chapter 12: Making Sure There Is Only One with the Singleton
Chapter 13: Picking the Right Class with a Factory
Chapter 14: Easier Object Construction with the Builder
Chapter 15: Assembling Your System with the Interpreter
PART III: Patterns for Ruby
Chapter 16: Opening Up Your System with Domain-Specific Languages
Chapter 17: Creating Custom Objects with Meta-programming
Chapter 18: Convention Over Configuration
Chapter 19: Conclusion
Appendix A: Getting Hold of Ruby
Appendix B: Digging Deeper
Simply put, this book is intended for developers who want to know how to build significant software in Ruby. I assume that you are familiar with object-oriented programming, but you don’t really need any knowledge of design patterns—you can pick that up as you go through the book.
You also don’t need a lot of Ruby knowledge to read this book profitably. You will find a quick introduction to the language in Chapter 2, and I try to explain any Ruby- specific language issues as we go.
How Is This Book Organized?
This book is divided into three parts. First come a couple of introductory chapters, starting with the briefest outline of the history and background of the whole design patterns movement, and ending with a quick tour of the Ruby language at the “just enough to be dangerous” level.
Part 2, which takes up the bulk of these pages, looks at a number of the original Gang of Four patterns from a Ruby point of view. Which problem is this pattern trying to solve? What does the traditional implementation of the pattern—the implementation given by the Gang of Four—look like in Ruby? Does the traditional implementation make sense in Ruby? Does Ruby provide us with any alternatives that might make solving the problem easier?
Part 3 of this book looks at three patterns that have emerged with the introduction and expanded use of Ruby