Book Review: POODR by Sandi Metz


No matter what other people say, to be a decent tester you have to be a decent developer. A person just can’t be called a tester if they don’t have a good understanding about development and design techniques.

In this post, I review Sandi Metz’s book “Practical Object-Oriented Design in Ruby” to see how it holds up against design and testing.

I’ll be up-front about what I think about this book: READ IT!

I was rather surprised how, even though the book starts with simple examples, it quickly develops and builds on them to provide good explanations.

Chapter 3, Managing Dependencies, introduces the concept of dependency injection (parameter-passing). This is a key chapter to read for any novice developer, as they are most likely apt to incorrectly create dependent-laden classes in the belief that their “train-wrecks“, as Sandi puts it, is a thing to be proud of.

Speaking of train-wrecks, Sandi introduces this useful concept in chapter 4, where she talks about flexible dependencies. In this chapter, she uses sequence diagrams beautifully and without the bloat that typically makes this tool useless.

I really like how Sandi introduces the law of Demeter in a very flexible manner: it’s not a law, and it can be broken. Bingo! This is what a lot of developers struggle with, so I was glad to see Sandi’s perspective on it.

Chapter 5 is, in my opinion, the most “Ruby” of all chapters, as it’s all about duck-typing. It introduces and explains the concept beautifully, from how to recognize important messages, how to centralize those messages and how to structure (i.e. architect) your classes so that they’re easy to modify later on exactly because of duck-typing.

Chapter 6 explains inheritance, but it’s not a dull ride. It exposes the pitalls that typical OOD books don’t address and were only encountered after years of experience (and pain) by inheritance gone wrong.

Remember AOP and cross-cutting concerns? Mixins are wonderful solutions for exactly that. Chapter 7 is all about mixins (another Rubyism) and roles. Messages are a central theme in Sandi’s book, not classes. This chapter describes several interesting and excellent tips to centralize common roles into modules and mix them into Ruby classes effectively.

I’ll be honest with you: even though it looks fantastic, I skipped chapter 8 just to get to chapter 9: Designing Cost-effective tests. Don’t worry though, I’ll add my chapter 8 review as soon as I read it.

So chapter 9 is all about testing your Ruby (and OO) code. This chapter not only explains the advantages and limitations of mocks, doubles and stubs, but illustrates their benefits brilliantly while making their pitfalls painfully apparent. With the exception of a few missing sections (like the one mentioned in page 212 “Proving the Correctness of Ducks”), this is by far the best chapter of the book that no real tester will want to miss!

This book gets a solid thumbs up.

So get your POODR and start reading! You won’t be disappointed, and you’ll become a better tester.

Leave a comment

Your email address will not be published. Required fields are marked *