This book is about writing cost-effective, maintainable, and pleasing code … [by] … finding the right abstractions.
Sandi Metz, Katrina Owen. 99 Bottles of OOP (Kindle Locations 119–120, 213). Kindle Edition.
Sandi is a programmer, teacher, author and consultant.
Katrina is a Golang and Ruby programmer, and the creator of Exercism.
This book is available in two versions: 99 Bottles of Beer and 99 Bottles of Milk.
The book has 187 code examples excluding the appendix. All code is written in Ruby.
The Kindle version of the book is in Mobi format, and I’ve noticed some indentation problems. The Epub version opened with Mac OS Book has no indentation problem, but it’s missing syntax colors for the code. The PDF format has colored syntax and has no indentation problem.
The book will interest you if you are looking to improve your Object-Oriented Design (OOD) skills.
“99 Bottles of OOP” is suitable for both beginner and experienced Object-Oriented programmers.
“novices often have an easier time with this material. As they are unencumbered by prior knowledge, their minds are open, and easily absorb these ideas… if you are a veteran, it’s best to adopt the novice mindset before reading on. Set aside prior beliefs, and dedicate yourself to what follows.”
Excerpt From: Sandi Metz, Katrina Owen. “99 Bottles of OOP.” Apple Books.
How to read
Sequentially, chapters depend on one another.
The best learning result is achieved by working through the code samples in the book.
Prior knowledge of Ruby is not required. The code is easy to read and Ruby is used without its distinctive features and all the ideas learned are applicable to all OOP languages. If you understand the code examples, you can work through the exercises in any programming language that you are comfortable with. You can check out the code exercises from all chapters here.
The first chapter introduces the problems as well as the metrics to objectively compare the effectiveness of each suggested design. Before you start reading this chapter, it is recommended you make an attempt to solve the problems yourself.
The 2nd chapter is about Test Driven Development (TDD). This chapter covers how to incrementally write tests that drive the development of a project. This approach leads to writing better-designed code.
The 3rd chapter is about how to handle new product requirements. It talks about those feelings you get when you no longer like the code that results from adding new features. This chapter shares techniques on how to handle these problems with the Open/Close principle. You will learn how to apply this principle to identify and remove code smells that make it difficult to see hidden abstractions in your code.
The 4th chapter continues to practice ideas from the 3rd chapter with slightly more complex tasks. It touches on the importance of consistency in your code, which empowers you to refactor and lower costs by writing code that’s easier to read and maintain, in the first place. The chapter emphasizes the importance of sticking with refactoring rules. It also explains the Liskov substitution principle.
The 5th chapter demonstrates the next smell in the code. It explains the importance of messaging in OOP and how to fix bad messaging by applying extract className refactoring. Also, the chapter discusses topics such as premature performance optimization, caching and immutability.
In the 6th chapter, the authors explain how to solve one of the key requirements introduced earlier in the book. In order to do this, you explore the Data clump code smell and replace if/switch statements with a set of polymorphic objects created by a factory.
The book is well structured. It uses a lot of difficult words throughout the chapters. If you are not a native English speaker, like me, this book will be harder for you to follow. On the plus side, however, you will learn 1 to 3 new words and phrasal verbs, on average, in each section.
I found this book to be rich in ideas unfamiliar to me. Which was a welcome surprise, because I have over 5 years of experience in writing OOP code. It’s safe to say I learned a lot from this book.
I enjoyed skipping ahead to solve the problems in the next chapters before I read them, and then I would compare my results with the author’s to see how our approaches to the problem differed
The content of the book goes deep into a few particular concepts and overall the scope covered in the book is narrow as a result.
I would recommend the POODR book (or the 2nd edition, although I haven't had the opportunity to read it yet) by Sandi Metz as a complementary material for “99 Bottles Of OOP”. I personally read the first edition of POODR twice and am going to read the second edition. POODR is totally worth the price.