This repository is a collection of working examples of the Gang of Four Design Patterns written in Ruby. I am doing this as part of my personal studying and preparation for a weekly design patterns discussion at Eden Development.
Sometimes i follow the pattern given in the book, other times i make up my own. As a study group, we are working through the book in the order suggested by A Learning Guide To Design Patterns so my examples will probably appear in the same order.
My examples have tests which can be run by running test.rb
in the appropriate directory. For example:
These are the patterns that i have implemented so far:
- The basic creational non-pattern used as a basis for the rest of the creational patterns
- Factory Method
- Strategy
- Decorator
- Composite
- Iterator
- Template Method
- Abstract Factory
- Builder
- Singleton
Please feel welcome to comment, add your feedback, suggest alternative implementations, point out my errors, and of course use for your own study and benefit. For a fast reference on how to implement design patterns in Ruby, i also recommend shvets/design_patterns_in_ruby.