42 of 42 people found the following review helpful
on February 7, 2008
Warning: This book is not a reference!!!
Well, it could be but it probably won't need to be as each concept is explained so well that you will remember when to apply this pattern or that pattern for every situation. The author is engaging and funny making this quite a book turner for a technical book. I almost read half the book on the 2 hour commuter flight between Perth and Karatha. Every chapter starts with a little anectode about the author's past life events and how these are related to the use of a particular pattern. The examples are well thought out and the author also discusses Ruby specific implementation details as well as providing valuable insights into how each pattern is used in the existing Ruby codebase.
I come from a Python/C/C++/Java background and have been tinkering around with ruby for a while but without really "getting it" and understanding what the fuss was about. The same could be said about design patterns. After reading this book I have finally grokked, not only Ruby but the value and power of design patterns. I can now say that I truly understand exactly why there is such a hype about Ruby. The whole method_missing thing, singleton support, ability to clone classes, etc. This language really represents the future of programming - today - and this book delivers on its intent.
This is simply one of the best technical books that I have read in a long time and I thoroughly recommend it, especially for an intermediate Ruby programmer and even those who know OO concepts and principles but may be new to Ruby.
22 of 22 people found the following review helpful
on January 13, 2008
I just finished this book, cover to cover. I rarely read books like this all the way through. I scan them and keep them around in case they help me out of a jam. But this book is different. It is formative in the sense that the original Gang of Four (GoF) book on patterns was formative: it asks us to think about our problems in fresh ways.
One important part of this book, however, stresses the use and overuse of these patterns. Olsen emphasizes that this isn't a competition to use all the patterns. Whoever has the most patterns doesn't necessarily win. Whoever uses code gracefully and simply does. It reminds me of the talk by Marcel Molina Jr. at RubyConf 07, speaking about what makes code beautiful. It's the proportion, integrity, and clarity that makes beautiful code. I.e., we keep the code as simple as we can, keep it focused on the problem at hand, and we do it clearly. This book warns against misuse or abuse of patterns as much as it teaches the patterns themselves.
Another thing that I found very useful about this book is it suggests simpler ways for my existing code. This tells me that, though I was happy with the function of what I could do once, the form can improve that it doesn't fall apart in the face of future iterations.
Finally, I enjoy how each chapter evolves. We start with a rigorous interpretation of the GoF patterns, then Olsen introduces simpler ways to implement the ideas that take into account Ruby's available economies. So, we write simpler code, understand the tradoffs of the various alternative implementation methods, and understand the patterns themselves more concretely.
Other than the occasional loose editing that come up from time to time, I really wouldn't change what was written. I would have enjoyed more chapters on other patterns, even some that are outside the scope of the GoF book. But that's just a reflection of my respect for Olsen's love of the material and skill in teaching it.
If you're picking up Ruby to write Rails code, maybe start with the Agile Development book. If you've finished your first personal Rails project, or you have other uses of Ruby in mind, I'd suggest this as the next book you pick up. After this book, I'd next suggest The Ruby Way by Hal Fulton. That's probably the fastest way to pick up Ruby in a professional context.
8 of 8 people found the following review helpful
on July 27, 2008
I never really understood the need for Design Patterns. After reading several blogs, and listening to other programmers, I thought that Design Patterns might even somehow be harmful to my programming education. I felt that just by learning what they were, I'd somehow pollute my thinking to the point where I wouldn't be able to program without seeing a pattern in there somewhere. When I heard of the book Design Patterns in Ruby, I flinched. What good could possibly come from introducing Design Patterns into Ruby, I asked myself? Fortunately, my initial prejudices were unfounded. Design Patterns in Ruby is not some secret plot to turn all of the Ruby programmers into mindless drones; it is a very thorough introduction to Ruby, Design Patterns, and Object Oriented Programming concepts. Design Patterns in Ruby helped me to finally look critically at Design Patterns, and see them as something not to be feared, but as something that could be useful, even in my Ruby programming.
Design Patterns in Ruby is written with the idea that while the reader might be a good programmer, they may have somehow missed what Design Patterns are, or the reader might not know much about Ruby. The first two chapters rectify this by introducing the reader to what exactly these Design Patterns are. The author explains precisely which of the 14 of the original 23 "Gang of Four" patterns are covered in the book, and reasons why the 14 patterns were chosen. Chapter 2 is a quick introduction to Ruby, just to ensure everyone is on the same page. The author, in a single chapter, clearly explained concepts that other books I have read couldn't clearly convey, even after several chapters. Any doubts that I had of the author's abilities in explaining Design Patterns in a way that I would understand were completely gone by these chapters.
The actual Design Patterns in Design Patterns in Ruby have a similar format throughout the rest of the book. First, a small anecdote begins the chapter, explaining either a real-life situation where the patterns would be handy, or tying the pattern to one of the other patterns in the book. The meat of the chapter describes how one would implement the pattern, usually starting with a direct port from another language like C++ or Java, and gradually working it into something more Ruby-like by the end of the section. After the pattern is worked into a more Ruby-like format, the author then describes how to really abuse the pattern. Lastly, the author points out where this pattern is used in the Ruby, Rails, or other Ruby code, followed by a quick summary. This format works quite well, especially for programmers just starting in both Ruby and Design Patterns, while advanced programmers will learn better and more effective ways for implementing (or abusing) the patterns. Providing where the pattern is used in the code is also an excellent learning tool for the reader, and gives a baseline for the reader on where to look for more examples. The format also makes the book engaging. I found myself wanting to read the book, which is an experience I can't say I shared with the original Gang of Four Design Patterns book.
In addition to 14 of the Gang of Four patterns, the author talks about three Ruby-specific patterns. The first is the Domain Specific Language (DSL) pattern. Rather than defaulting to discussing Active Record (arguably the most famous DSL in Ruby), the author actually creates a DSL called "PackRat" which is a language for managing backups. The second pattern is Metaprogramming, which is ubiquitous in Ruby. The last pattern in the book is Configuration Over Configuration, the mantra of Rails. Each of these patterns compliments the other patterns in the book, and add to the original patterns discussed earlier in the book.
Design Patterns in Ruby is an exceptional book. It distills the best of the "Gang of Four" patterns that are of significance to Ruby Programmers, while adding several patterns that show up throughout Ruby and Ruby on Rails code. The author's style and the book's format make for an easy and informative reading experience. I can heartily recommend this book for all Ruby developers, both beginners and experts, and can especially recommend this book for those like myself who didn't think the original Design Patterns was anything to give attention. Design Patterns in Ruby has earned a permanent place on my shelf.
10 of 12 people found the following review helpful
on January 4, 2008
At first glance, Ruby looks like any other dynamically typed language. Statements are sequential, it boast strong support for Object Oriented Programming, and it has all the basic control structures with which are are intimately familiar. After working with Ruby, and the constantly evolving Rails web framework, it's clear that Ruby is different from Python or Java, and that its differences make it very special.
That's why Design Patterns in Ruby is a great reference book, not because it discusses the Gang of Four patterns that any experienced developer knows by heart after years of practice, but because it demonstrates practical usages of many of the more advanced topics in the Ruby language. Extending an Object or Class at runtime, on-the-fly? Check. Magic methods? Check. Blocks, Procs and lambdas? Check. DSLs? Metaprogramming? Check, check. This book is short, but it has everything needed for a developer to understand the advanced concepts of Ruby.
Take warning, though. If you are just starting in Ruby, this is NOT the book for you, and many concepts will go over your head.
6 of 7 people found the following review helpful
on March 28, 2008
For many the idea of bringing design patterns to ruby is a terrifying one. Having taken refuge from over-engineered java projects (or for that matter, attempts to apply java engineering approaches to a somewhat dynamic language like PHP) the baggage that often goes along with design patterns isn't what a recent convert is looking for. But as I mentioned in my last review of a design patterns volume, and series editor Obie Fernandez highlights in his foreword, design patterns don't have to be used that way and maintain merit when used as a source of collective experience and shared language.
Russ Olsen's book does a good job of stepping through the key patterns from the Gang of Four's initial offering, showing how they can be applied to and simplified with Ruby, introducing along the way various uses of blocks, mix-ins, and other powerful features of the language that may be unfamiliar to newcomers. Each chapter highlights how the pattern can be used or abused, sounding a note of caution to dissuade unthinking embrace of every pattern between its covers. It's clearly written with a nice balance of code to prose.
Towards the end of the book a couple of "new" patterns are offered, particularly "internal DSLs", "meta-programming" and "convention over configuration." Opinions differ over whether of those can really be considered patterns in the general sense of the term. Certainly those concepts are examples of a community gradually refining its approaches to common problems, but at least two of them are considerably more conceptual and abstract than most of the other patterns in the book. Perhaps the best way to understand them is as giving an insight into the working patterns of the ruby community approaches problems, and pointers to topics worthy of more exploration.
That usage of the final few chapters gives some indication of the probable audience for this book. It seems best suited to those who have dabbled with ruby but don't yet have much experience. A general sense of syntax is all you'll need going in, but you'll come away with a much stronger sense of the language's features than that. Similarly it'll work well for those with a general sense of the major patterns but who could do with a refresher, maybe while transitioning from java or other "enterprisey" development to ruby.
While it won't have the same general appeal of other titles in the series like The Ruby Way, Second Edition: Solutions and Techniques in Ruby Programming (2nd Edition) (Addison-Wesley Professional Ruby Series) and The Rails Way (Addison-Wesley Professional Ruby Series), this is a handy volume in a series that is making strong contributions to the ruby book market.
Disclaimer: I was sent a copy of this book for review by the publisher. There were a few pages missing due to a printing defect so I wan't able to read parts of chapters 13 or 14.
3 of 3 people found the following review helpful
on April 2, 2009
Format: HardcoverVerified Purchase
If you have been programming for any extended period of time, I am sure you have started to see different patterns emerging out of your tasks. You may find you are doing the same thing over and over again, solving problems that you had previously solved in another project. These patterns can vary from smaller chunks of re-usable code, to manage the sending and receiving of email, all the way to watching over a part of your application and triggering notifications to another part of your application. This book, Design Patterns in Ruby takes several of the principles found in the widely known book, Design Patterns by The Gang of Four, and applies them to Ruby. It's a mixture of the theory behind the design patterns, and then hands-on practice applying it to your Ruby applications. While this book is centered around patterns in Ruby, it is not about teaching you Ruby. There is a brief primer in the beginning, but it comes with the understanding that you already know a little bit about the Ruby language. Now it's time to check out some of the patterns presented in this book.
WHAT ARE PATTERNS?
The book starts off with a chapter devoted to giving background to design patterns and how they can help you build better applications. This chapter isn't a history lesson. The main points of this chapter teach you about awareness. They teach you how to look at your applications, and when and where patterns could best be applied. He gives what he calls Patterns for Patterns while developing:
Separate out the things that change from the things that stay the same.
Program to an interface, not an implementation.
Prefer composition over inheritance.
Delegate, delegate, delegate.
You ain't gonna need it.
These principles provide us the glasses with which to look through as we assess our code. You will want to keep these in the back of your mind as you read through the rest of the book.
WHAT IS RUBY?
As I stated in the beginning, this book isn't about teaching you Ruby. However, the author does take the second chapter to walk you through the basics. This chapter simply shows you a bit of the syntax, types, and constructs. This intro is very brief, but probably enough to provide a reference throughout the rest of the book if you haven't worked with Ruby before. With this primer into Ruby, the author wraps up the first part of the book and we are now ready to move on to the 14 patterns covered in this book.
Spotting patterns might not always be easy, even with the guidelines given in the first chapter. One of the strengths of this book is that each chapter poses a different problem and then tackles is using the suggested pattern. This allows you to see it in action, and allows you to get the wheels spinning on how the pattern is used and where else it could be used. After walking through each of the patterns, we are presented with a nice wrap-up of the pattern.
This book is not very long in length, so I won't go into great detail with each of the patterns, as they are covered very well in each chapter. You need the context to understand how all of the pieces fit together. So, without providing too much information, here is a list of the patterns covered in the book:
If you are like me, then you will have read these chapters and be left with a desire to instantly start researching, practicing, and applying what you have learned. But we aren't done quite yet, there is still one more section to go. We now know what the patterns look like. We have seen the examples done solely in Ruby. Everything makes sense. But can we do more? Now we shift gears to look at patterns found in the Ruby language itself.
THE PATTERNS + RUBY
The Ruby language itself has several patterns that make programming Ruby fun and elegant. The last part of this book shows us a few of those patterns, as they can be used extensively while building your application patterns. If you have ever browsed through the Ruby on Rails source code, then you will have seen all of the patterns listed above, as well as the patterns in Ruby. Here are a few of those:
Convention over configuration
Ruby is such an elegant language to work with, and it is due in many parts to these patterns found within the language. These aren't patterns solely used by Ruby, but the English-like nature of Ruby makes it fun to both read and write with these patterns.
This book fits nicely with the Addison Wesley Professional Ruby Series, but doesn't require you to read all other books in the series to fully comprehend. While the progression of this book was done very well, starting you off with a discussion of patterns and Ruby, then diving right into the patterns, I did find myself reading this book several times. I didn't read it several times because I didn't understand it, but simply to read with a new outlook on how and where these patterns could be applied, or are currently applied out in the wild. I find this book not only to be very informative, but also an excellent reference as I look to solve different problems. If you are a programmer, you should definitely read Design Patterns. If you are a Ruby programmer, you should then read Design Patterns in Ruby.
3 of 3 people found the following review helpful
on June 11, 2008
Format: HardcoverVerified Purchase
I am a Java developer whose Ruby experience is limited to firing up the interactive Ruby shell for a Hello World, or reading the first chapters of Programming Ruby before drifting away and vowing to learn Ruby "when I have more time". I work with the author, and purchased this book solely on the strength of his training courses and lectures. Russ Olsen in book-format is just as effective a teacher as he is in person.
The book is a hybrid reference/Ruby-introduction book which provides the best of both worlds -- I was able to read it cover-to-cover without losing interest, something I could never quite accomplish with the original GoF Design Patterns text. Each chapter also functions as a modular unit, with concise introductions and conclusions that will be great on a day when I pull it off my shelf for use as a reference book. The Design Patterns provide a nice playpen for the sections on Ruby coding practices and features, and the coding sections give a better context for the Patterns.
Each Pattern is discussed in theory and in real-world code, and the author is very clear about the benefits and pitfalls of employing them. In addition, the book provides a solid, likable profile of the Ruby language without the evangelizing common in other books. Code examples are concise and useful, and the writing style is humorously engaging without falling into the trap where engineers-turned-authors suddenly believe they are stand-up comedians and sprinkle every paragraph with a multitude of grating jokes. There were a few mistakes in the text, but all of them were already captured and corrected on the book's web site.
In my library of tech books, the best books, the ones I constantly revisit, are not the ones that show me how to do something -- they are the ones that place what I do in a wider context and show me the possibilities of what CAN be done. Although I do not currently use Ruby in my day-to-day work, I can see this book becoming invaluable when that day comes.
3 of 3 people found the following review helpful
on September 2, 2013
Format: Kindle EditionVerified Purchase
After reading Russ Olsen's Eloquent Ruby years ago, I knew this was a guy who could write. I have recommended that book to numerous people since then, and recently when I was searching for it I found this book. It does not disappoint. If you have read the "gang of four" Design Patterns book you'll recognize most of what Olsen writes about here. But what is amazing and cool is that the book is for rubyists and he demonstrates patterns that are regularly relevant to those of us writing ruby professionally (that includes Rails). And of course there are opportunities to use the beauty of ruby to do in a few lines what I did in many in C++ and Java, so it continues in the vein of instruction I loved so much in Eloquent Ruby. There are even some ruby-specific patterns at the end. I have been writing ruby since 2008 or thereabouts and have written a lot of bad code, and read far more bad code. Read and understand Olsen's books and do the world a favor by seeing ways to follow clean, elegant, simple and regular patterns that make your ruby beautiful.
2 of 2 people found the following review helpful
on October 17, 2010
This is the kind of technical book that comes along maybe once a decade or so: absorbing, informative, and useful to both a novice and expert alike. I found myself reading this book like a best-selling novel, I simply couldn't put it down! I had always thought patterns to be a rather dry (pun intended!) subject, something absolutely necessary for the success of an OO system, but intrinsically dull. Olsen actually breathes life back into patterns and conveying the material in a way that actually makes you want to utilize them instead of dreading the prospect of using them. If only the GoF book were written like this! The other unique quality of this book is that it can be used as an introduction to ruby as well. THe first 2 chapters present the essentials of the ruby language so that a complete novice can use this book as her main text and the oreilly The Ruby Programming Language as a reference book. All in all a gem (pun intended!) of a book!
2 of 2 people found the following review helpful
on May 28, 2008
Not sure how to start, so I'll just write what I'm thinking: What a well-written book!
After some general programming/patterns advice, Russ launches into the individual patterns. Each chapter starts out by relating the pattern to a human activity, specifically something that occurred in Russ's childhood. That might sound lame, but it was surprisingly refreshing and effective.
He then proceeds to illustrate the pattern with a simple, understandable, and relative programming example. He usually starts out with the implementation that first comes to mind, then illustrates the shortcomings of the approach to show why it's a bad idea.
He follows up with the right way (or one of the right ways) to solve the problem, addressing the pros (and cons) of the approach.
He ends each chapter with a discussion on using and abusing the pattern, and where the pattern can be found in the real world.