Practical Object-Oriented Design in Ruby: An Agile Primer (Addison-Wesley Professional Ruby) 1st Edition
| Sandi Metz (Author) Find all the books, read about the author, and more. See search results for this author |
Use the Amazon App to scan ISBNs and compare prices.
There is a newer edition of this item:
Ruby’s widely admired ease of use has a downside: Too many Ruby and Rails applications have been created without concern for their long-term maintenance or evolution. The Web is awash in Ruby code that is now virtually impossible to change or extend. This text helps you solve that problem by using powerful real-world object-oriented design techniques, which it thoroughly explains using simple and practical Ruby examples.
Sandi Metz has distilled a lifetime of conversations and presentations about object-oriented design into a set of Ruby-focused practices for crafting manageable, extensible, and pleasing code. She shows you how to build new applications that can survive success and repair existing applications that have become impossible to change. Each technique is illustrated with extended examples, all downloadable from the companion Web site, poodr.info.
The first title to focus squarely on object-oriented Ruby application design, Practical Object-Oriented Design in Ruby will guide you to superior outcomes, whatever your previous Ruby experience. Novice Ruby programmers will find specific rules to live by; intermediate Ruby programmers will find valuable principles they can flexibly interpret and apply; and advanced Ruby programmers will find a common language they can use to lead development and guide their colleagues.
This guide will help you
- Understand how object-oriented programming can help you craft Ruby code that is easier to maintain and upgrade
- Decide what belongs in a single Ruby class
- Avoid entangling objects that should be kept separate
- Define flexible interfaces among objects
- Reduce programming overhead costs with duck typing
- Successfully apply inheritance
- Build objects via composition
- Design cost-effective tests
- Solve common problems associated with poorly designed Ruby code
Frequently bought together
Customers who viewed this item also viewed
Editorial Reviews
About the Author
Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.
Product details
- Publisher : Addison-Wesley Professional; 1st edition (September 5, 2012)
- Language : English
- Paperback : 247 pages
- ISBN-10 : 0321721330
- ISBN-13 : 978-0321721334
- Item Weight : 1.2 pounds
- Dimensions : 7 x 0.8 x 9 inches
- Best Sellers Rank: #338,234 in Books (See Top 100 in Books)
- #29 in Ruby Programming
- #101 in Object-Oriented Software Design
- #274 in Data Processing
- Customer Reviews:
About the author

I am a programmer. In the past 30+ years I have written innumerable applications, many of which are still running today. Dealing with long lived applications has left me deeply biased towards practical solutions that produce working software that is easy to change.
I am also someone who explains things, but I have difficulty speaking without drawing on the whiteboard and feel inarticulate unless the conversation includes at least three colors.
I believe in simplicity; simple code, and straightforward explanations, and strive for it in my code and in my writing.
Customer reviews
Top reviews from the United States
There was a problem filtering reviews right now. Please try again later.
Tip: Watching Sandi Metz' presentations at conferences which is readily available on YouTube is a good complementary material to this book.
On the other hand, for an experienced Ruby developer, this book can also be a little boring if you're already familiar with many of the ideas. You still gain better understanding of the concepts but it can feel a little slow.
I'm also not a fan of the Kindle format in general and this book is not an exception. I'm pretty sure the physical book has a much better formatting, but I try to avoid having too many physical books at home. If you're undecided between getting the physical or digital copy and you don't have a strong preference, get the physical book.
What was most interesting (and something you don't see in a lot of software book) was how Sandi describes how a senior software designer will make decisions, while considering the technical debt that comes with those decisions. I have been working in software for over 20 years and this is what I find is missing when it comes to a lot of books out there. There's the idealized view of what software is, and then there's reality. In "real life", you have a limited amount of time to do your job and you only have a portion of the real system requirements. The question is how do you create your software so that future refactoring will be easy... this is what design is all about. The best way to make sure your software is refactorable is through the "micro" level design decisions you make, it's by making sure that you have single responsibility classes, it's by reducing coupling, etc. (I don't know of any good software that came out of an ivory tower architecture, good architectures that I have seen usually migrate from bottom-up).
This book is bang on with regards to this. It goes over the "micro" level design decisions that you have to make. It gives practical tips on how and why you would make these decisions.
There's also a very good chapter on testing, which explains some of the problems you'll find testing with dynamic languages. I especially like the way Sandi describe the "false positive" that can happen in the BDD and TDD worlds. It's made very clear and I like the solution that she describes to this problem.
In the last couple of years, I have read a number of books on Ruby and Rails. There's two that stand out... Eloquent Ruby and this one. I would recommend this book to anybody starting out in Ruby (junior or senior).
One caveat though... The ideas described in this book can be applied to most dynamic languages but some of the concepts might be counterintuitive if you come from a statically typed language. (For example, the use of duck types is not something you see in Java for example. In static (compiled) languages, you are trained to extract interfaces and to make things as strongly types as possible. This doesn't make sense with dynamic languages).
In any case, I highly recommend the book.
The only real ding to the book is Chapter 8's references to Enumerable and Forwardable. Everything else in the book was either easy to read or well explained. These two characters seem to have slipped in without fanfare or explanation. I don't understand them and thus probably missed some of the book's goodness. Perhaps I'll get it later. I still rate this book a 5 star buy!
Unfortunately, with a codebase of any interesting size, those conventions aren't sufficient for preventing chaos. Huge helper files? Big junk drawer, er, lib directory? For projects that come in at that stage, I've started recommending that the developers all stop coding for a day and read Sandi Metz's book. Learning how to create the right objects that send the right messages is a crucial skill for moving your Rails app into the big time.
Sandi has an amazing way of picking out the parts of Design-with-a-capital-D that are actually useful in a modern agile process, while leaving aside the waterfall trappings that typically accompany them. If you've ever read an article about software design and thought, "That's a nice theory, but these people have no idea how modern software is actually written" - then this book is for you. It's what happens when design intersects practice.
After I read this book it totally changed my thought prcocess for writting new code and answers to fixing bad code. A I went through the book I ran into every tricky, paint yourself in a corner no,no. in our work code and understood why it was so hard to fix. Some of the code I trashed and wrote it the correct way. Thank You for this book and making it so clear. There are 2 coding example errors in the code but I know ruby so I saw them immediately. Still those errors are small change, this book is about understanding OOP concepts.
Top reviews from other countries
Two of the really stand out moments in the book for me:
1. I have known about SRP and the act of assigning responsibilities to objects so this was not new, but in chapter 4 the emphasis is switched to the messages passing between objects and using this to drive out what objects are needed this was a real eye opener for me and has changed the way I go about designing software
2. Unit testing has always felt like a tricky balance between going overboard and creating unit tests that are so ingrained with how each object does it's work that making a change requires all the related tests to be changed which then leads to the other end of the spectrum were we are so burned by this that we start to leave out unit tests for fearing what will happen when we want to make a change to an objects behaviour. In chapter 9 the author writes what I would consider should be compulsory reading for anyone before embarking on using unit tests especially TDD/BDD to know from the start how to go about writing unit tests correctly.
If your worried about it using Ruby, don't be I come from a C# background and have never written a line of Ruby, it's such an expressive language it shouldn't matter what language background you come from you will get tremendous value from this book.
A focus on making the pieces of your app easy to change and reuse make this an extremely useful book for programmers of all levels.
This book has really helped me to step up my understanding of OOP and has opened my eyes to a number of concepts that I'd never considered that will greatly improve my code going forward.
Can't recommend this book enough.
This book will help you to: create designs using building blocks that have a single responsibility, minime dependencies in them, create flexible, trustworthy and re-usable interfaces, properly use inheritance and understand when you should do, and much more.
This book will help you realise why the gang of four patterns bring the qualities they do to the problems they were created to solve. You will understand the principles behind them.
Don't let the word "Ruby" in this book put you off. This book serves as general object oriented design book, and if you have experience in statically typed languages, it will also allow you to realise the extra constructs necessary on them to essentially achieve the same level of decoupling that Ruby naturally allows.
Easy to read. Good examples. Small, concise and straight to the point!
Excellent!
Written for Ruby - it is equally applicable to Python.
When to use duck typing or composition, dependency injection or mixins, etc.
The code samples are minimal, as is any practical application. So this is the opposite of a Cookbook, or Manual.
But having read plenty of those recently, I felt it was all the better for that.
A pleasure to read, I would recommend this book to anyone for the clarity of its walk through of OOP design approaches available in a Ruby / Python type of language.
Magnifique







