It turns out that everything you need to know about Object-Oriented Design (OOD) can be
learned from the "99 Bottles of Beer" song.
Well, perhaps not everything, but quite certainly a great many things.
The song is simultaneously easy to understand and full of hidden complexity, which makes it the
perfect skeleton upon which to hang lessons in OOD. The lessons embedded within the song are
so useful, and so broad, that over the last three years it has become a core part of the curriculum
of Sandi Metz’s Practical Object-Oriented Design course.
The thoughts in this book reflect countless hours of discussion and collaboration between Sandi,
Katrina Owen, and TJ Stankus. These ideas have been battle-tested by hundreds of students, and
refined by a series of deeply thoughtful co-instructors, beginning with Katrina. While none of the
authors have the hubris to claim perfect understanding, all have learned a great deal about
Object-Oriented Design from teaching this song, and feel compelled to write it all down.
Therefore, this book, now in its second edition. We hope that you find it both useful and
enjoyable.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
【One-Line Pitch】
A hands-on guide that uses the "99 Bottles of Beer" song to teach practical object-oriented design: how to move from working-but-messy code to flexible, well-factored code through disciplined refactoring and test-driven development. Best for developers who can write code but want to think more clearly about design, duplication, and change.
【Book Arc】
- **Opening (~0%–10%)**: Frames the book's premise—the song is simple to understand yet hides real complexity—and introduces the central tension between DRY code and the cost of understanding. It critiques an "Incomprehensibly Concise" first attempt that is technically DRY but expensive to change.
- **Early (~10%–30%)**: Establishes the workflow: write a failing test, get to "Shameless Green" (the simplest code that passes), then refactor. Introduces test structure (setup, do, verify), cyclomatic complexity as a rough guide, and the problem of conditionals multiplying as requirements change (the "six-pack" requirement).
- **Middle (~30%–55%)**: The core methodology—the Flocking Rules—is applied iteratively. Readers learn to find the verses most alike, replace differences with sameness, extract concepts into named methods, and gradually cut over refactorings using defaulted arguments as temporary shims. The chapter walks through removing special cases for verses 2, 1, and 0 until a single abstract template produces every verse.
- **Late (~55%–85%)**: Excerpts do not cover this range in detail; based on the arc, this stage likely returns to the six-pack problem and extends the design to handle new requirements, testing whether the refactored code is genuinely open to change.
- **Ending (~85%–100%)**: Excerpts do not cover the closing chapters; the book presumably consolidates lessons on OO mindset, naming, and judging design quality.
【Key Takeaways】
- **DRY is not free** (Opening): Every extraction adds indirection, which raises the cost of understanding. Duplication removal only pays off when it lowers the cost of change more than it raises comprehension cost.
- **Shameless Green first, design second** (Early): Write the simplest code that passes tests—even if it contains duplication and conditionals—then refactor once requirements are clear. Premature abstraction is a trap.
- **Conditionals are the bane of OO** (Early): Each new special case (like the six-pack) compounds branching logic. The goal is to replace case statements with polymorphic, message-driven code.
- **The Flocking Rules provide a repeatable refactoring path** (Middle): Find the most alike cases, make them more alike step by step, then identical; extract each difference into a named method and send messages instead of embedding logic.
- **Name concepts, not syntax** (Middle): Methods like `container`, `quantity`, `pronoun`, and `action` capture domain meaning. Good names make the code's story legible and reduce mental clutter.
- **Gradual cutover keeps code deployable** (Middle): Use defaulted arguments (e.g., `:FIXME`) as temporary shims so some callers can pass new arguments while others remain unchanged—then clean up.
- **"Sending messages" vs. "calling methods"** (Opening): The message-sending mindset encourages senders to be ignorant of receiver implementation, fostering independence and maintainability.
- **Tests drive specificity** (Early): As tests get more specific, well-factored code gets more generic; poorly factored code stays equally specific, accumulating one branch per case.
【Reading Tips】
- **Deep-read the Flocking Rules chapters** (Middle): This is the book's methodological core. Follow the step-by-step refactorings with the code in front of you—the value is in the process, not the final listing.
- **Skim the early critique of "Incomprehensibly Concise"** if you already understand DRY trade-offs; focus instead on the transition to Shameless Green.
- **Do the exercises**: The book is designed as a practicum. Attempt each refactoring before reading the solution; the lessons stick through doing, not reading.
- **Watch for hard spots**: The gradual cutover with defaulted arguments and the iterative removal of special cases (verses 2, 1, 0) are the most demanding sections—slow down there.
- **Take away the mindset, not the Ruby**: The specific code is Ruby, but the principles—message sending, naming concepts, incremental refactoring—transfer to any OO language.
【Coverage Limits】
This guide is based on stratified excerpts covering roughly the first half of the book; the late and ending chapters (including the return to the six-pack problem and final consolidation) are not represented, so claims about those stages are inferred from the book's stated arc rather than excerpt content.
Page 9
1. Your purchase entitles you to a single, non-transferable license for your personal use of the ebook related files. You may read and download the ebook you...
e; there will never be a time when the code can do anything which is not explicitly tested. However, in Listing 2.8: Generalized Verse, as the tests get more...
concrete variant is a generalized verse abstraction. If you could find this abstraction, you could use it to reduce the four- branch case statement to a sing...
ous that: "99" must represent the same concept as: number-1 As always, you must name this concept, create a method, and send the message in place of the diff...
copy could be re-used in the following verse, saving seven more object creations for a total of eight altogether. Over the course of the song, caching could...
d, or occasionally return something you don’t expect, force you into a paranoid programming style. These untrustworthy objects require senders of messages to...
plug BottleVerse into Bottles and tests fail, the rules of refactoring say you must undo and fix the offending code. If you 5. Forward messages from the orig...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
99 Bottles of OOP A Practical Guide to Object-Oriented Design (Sandi Metz, Katrina Owen, TJ Stankus)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share to WeChat Moments
99 Bottles of OOP A Practical Guide to Object-Oriented Design (Sandi Metz, Katrina Owen, TJ Stankus)(Z-Library)
Scan the QR code with WeChat to open this book
Tap the ··· menu in the top-right corner
Choose Share to Moments
You are already in WeChat. Tap ··· in the top-right corner and choose Share to Moments.
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
99 Bottles of OOP A Practical Guide to Object-Oriented Design (Sandi Metz, Katrina Owen, TJ Stankus)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment