Book: Design Patterns in Ruby

Title: “Design Patterns in Ruby”
Author: Russ Olsen
Edition: Addison Wesley
Abstract: Getting better in Ruby using the Gang Of Four holy knowledge. From today I will read a chapter once a while and put my comments here. Reading such traditional sciences is a must-done for any hacker.
Pattern I: Template Pattern
Template Pattern aim to re-organize your code when a part of it only has to be flexible. Templates offer though an Abstract Class a kind of Interface. Using Hooks, available methods are easily over-ridden inside sub-classes. Main and central methods remains in the Abstract base Class and specializations are implemented inside children classes. Nothing complicated here but a pattern that allow us to easily modify of an Object by subclassing it.
Example: Change the behavior of WEBrick by adding a new template.
Pattern II: Strategy Pattern
A modern rule is “you can always delegate more”. Strategy Pattern extract the algorithm out into a separate object. Based on a Strategy all sub-classes (strategies) provide a different approach of the same action. The user, called the context, is implemented in a distinct Class and consequently there is a nice and strong separation between him and strategies.
The most direct connection with Ruby are Procs. A Proc is a chunck of code embeded in an Object. Doesnt that sound like a Strategy?
Example: Rdoc parsers can be extended using a new strategy