DEV Community

UponTheSky
UponTheSky

Posted on

[Book Review]Practical Object-Oriented Design: An Agile Primer Using Ruby by Sandi Metz

Why this book?

The reason I first bought this book was really nothing to do with OOP, design pattern, refactoring, agile, or any other productivity reasons. It was more than 2 years ago and I was a complete novice at programming. At that time I was interviewing with a Japanese company using Ruby on Rails heavily for their services. So I was learning Ruby intensively and I thought this book could enhance my knowledge and skill of Ruby programming.

However, after I become nothing to do with that company and I had a job of using JS/TS, I have had hardly any chance to read through the entire book. I was more enforced to learn the basic syntax of JS, frameworks, DevOps tools(like Docker) or basic CS knowledge(C++, Computer Systems, Computer Graphics, OS, etc.). Since I have recently quitted my job at the end of the last June, I had a bunch of time so I decided to read the books that I thought I should have read but I was unable to do so. This book Practical Object-Oriented Design: An Agile Primer Using Ruby was one of those books.

Yes, I finally have read through the whole book that I bought TWO YEARS AGO.

How was the book then?

Personally, I think this book is easy to approach. What I mean by "easy", is that a novice programmer who even don't have much experience in development, or has not read any books like Clean Code or Refactoring, could easily follow what the author is trying to say and show. You don't need much prerequisite knowledge for reading this book.

I myself is also a novice, and I only have read related books like TDD by Kent Beck or Clean Agile by Uncle Bob. So I myself found this book relatively easy to read through.

But more impressive features I felt are the followings:

principles rather than techniques

Rather than focusing on certain techniques such as dependency injection or template method pattern(although these techniques pop up while reading the book), the book relentlessly emphasize the importance of the OOD principles rather than specific design techniques. The author even says a programmer could be better off if one ignores such patterns when necessary, which I think is completely from a practical point of view.

Constantly recapitulated principles are the followings, as far as I can remember:

  • SW design is for reducing cost and responding to need of change
  • TRUE principle: code must be transparent(T), reasonable(R), usable(U), and exemplary(E)
  • when designing classes, messages are the core part of design
  • understand the role of each of the classes or objects

the way the book is structured

The story begins with an introduction to what is design in terms of programming, and then it moves to discussion about the important topics in OOD(object-oriented design). The OOD part starts from single class design to complex design regarding multiple classes such as duck-typing or inheritance. This order is good for understanding the whole picture: you start from a single tree, and you now see how a a forest and a mountain are filled with a bunch of trees. You don't forget important lessons of the single responsibility principle(SRP) while you are considering how to design composition structure between multiple classes in relation.

somewhat friendly examples

I guess the author really likes riding a bicycle. All the examples in this book are about bicycles. For those who are not familiar with objects like gear or cog, like me, may have to accept them as a part of a bicycle. But except that, the examples shown are not that hard to understand and easy to be seen around your daily lives.

good for Ruby(or any dynamically-typed language) users

Surely, as the title of the book suggests, this book is about writing an OOD in Ruby. I find this book is not that quite limited to Ruby users(so even JS or Python programmers would have not much problem with reading the book), but some parts of the book are closely related to Ruby-specific features such as modules(chapter 7) or minitest(chapter 9). And this book explicitly stands for the dynamically-typed language side. Thus one single chapter is dedicated to this side, duck typing(chapter 5).

So, who would you recommend this book?

Overall, I think this book is good for an introduction to OOD. For someone who don't have much knowledge w.r.t. this subject, this book might be helpful. As you read along the story the author tells you, you would be soaked with some practical knowledge about OOD. Rather than some exam-friendly knowledge such as design patterns or SOLID principles, you'll directly see how a certain OOD principle could be applied on a code chunk for refactoring.

On the other hand, those who are running out of time for preparing a job interview and you are hurry in learning such concepts in OOD, this book might not be for you. You'd be better go straight to read GoF or Clean Code, if you're preparing interviews. This book doesn't list out such keywords and explains what they are. It simply explains a big picture and general principles in OOD, and introduces a few keywords such as SRP or Liskov principle if it is necessary for story telling.

And of course, if you're a Ruby/Rails programmer, this book is probably a must-read for you. Full of Ruby code examples, and why not?!

Top comments (0)