I just finished reading Design Patterns in Ruby and think it is worth a mention even if you are a dedicated iPhone developer. If you are regular Ruby developer you should definitely check it out. I should clarify that when I say I read this book I really do mean I read it from cover to cover which is not something I can normally say for a book on software.
I mentioned the excellent Cocoa Design Patterns books a while ago which looks at common design patterns in the Cocoa frameworks. This book takes a slightly different perspective in that it focuses on 14 of the classic software design patterns from the so called “Gang of Four” book - Design Patterns: Elements of Reusable Object-Oriented Software. This latter book has a reputation for not being an easy read whereas Design Patterns in Ruby is very well written by Russ Olsen.
The design patterns that the book discusses are as follows:
- Template Method
- Factory Method
- Abstract Factory
The patterns that are not included are generally those that do not find frequent use in Ruby. In addition, in a section that is much closer to the Cocoa Design Patterns book there are three additional chapters on patterns that are very common in Ruby:
- Internal Domain-Specific Language (DSL)
- Convention Not Configuration
The book is written in a very readable style and I found it really increased by understanding of Ruby but also of when and how to apply common patterns in any language. The description of the Observer pattern for example is very easy to apply to the typical iPhone or Cocoa application.
I should also mention that the book starts with some good general advice on OO design and also a warning not to abuse design patterns by using them when it is not appropriate. Basically a design pattern is intended to solve a specific problem, applying a pattern to your code because you just read a pattern book and you want to try it out is likely to cause you some grief.
If you have any interest in Ruby you should check this book out. Like the Cocoa Design Patterns book it is not an introductory book but if you are coming to Ruby from another language such as Java or Objective-C it can help you to start thinking the Ruby way.