Nov 18, 2015
Table of contents:
There are many common problems that you will face day-to-day as a developer. A Design Pattern is a reusable solution that can help tackle these common problems and offer a clean and maintainable solution.
Using a Design Pattern is good because it is often the best solution to a given problem, but also it is recognisable to other developers.
This means that another developer will recognise the pattern and understand the problem you faced and the solution you arrived at.
It is also a good way of communicating potential solutions to a problem when talking about code.
Famously many of the most common design patterns come from “The Gang of Four” book Design Patterns: Elements of Reusable Object-Oriented Software.
This book was written a number of years ago but still is the best resource for learning design patterns.
Design Patterns in Ruby takes some of the most common patterns from the book and shows you how to implement them using Ruby. The book is written by Russ Olsen, who also wrote Eloquent Ruby.
Many of the foundational works of programming have stood the test of time for well over 10 years now. A lot these books tend to use languages such as C++, Java or .Net.
This is fine if you are familiar with these types of languages, but it can be a barrier to entry if you’re not.
If you’re first programming language is Ruby, you need to learn about these design patterns, but will be probably be put off by the syntax of C++.
Design Patterns in Ruby takes a handful of the most well used Design Patterns from the Gang of Four book and shows you how to implement them in Ruby.
Whilst each of the patterns is largely reproducible in any of a wide variety of languages, the dynamic nature of Ruby allows you to make some interesting implementation changes.
Russ does a great job of explaining each pattern using easy to understand examples given a problem.
He then shows you how to implement that design pattern in Ruby, and then iterates on the solution to show you how to improve it.
For certain patterns he also shows how you can leverage the unique characteristics and features of ruby to implement the pattern in a new way.
One of the problems with Design Patterns is, they are often used under the wrong circumstances.
Typically a Design Pattern is a great solution for a very specific set of problems, and a terrible solution for a whole host of other problems.
Russ does a good job of explaining the problem that is faced before showing the solution. This emphasises that this is a solution to a specific type of problem.
Russ also explores many features of the Ruby programming language. For example, he makes good use of blocks and procs, as well as strings, arrays and hashes. This means if you are totally new to Ruby you could probably pick this book up and leave with a fairly good understanding of the language.
I also liked the sections at the end of each chapter that listed prominent places where you could see the pattern being used in open source libraries as well as the section about “using and abusing the pattern”.
There wasn’t a whole lot that I disliked about the book to be honest, although, I think you would probably get more out of the book if you were already familiar with Design Patterns and Ruby.
Perhaps one criticism is that the book tries to do a lot. It tries to show you design patterns and teach you ruby at the same time.
Perhaps it would be better if a certain level of understanding of ruby is required, so the book could concentrate on the implementation of those patterns at a higher level.
This is a great book for both learning ruby and design patterns. If you’re new to either subject this is a great place to start.
You will learn a lot of ruby, and you will get a good understanding of design patterns.
If you’re new to ruby and you want to learn design patterns, this is a perfect place to start. But even if you’re very familiar with ruby, you will probably get a lot out of the book because it’s always good to see implementations of solution when faced with a given problem.