The Concise Guide to Substitutability is a 40 page ebook that will teach you to recognize why duck typing is sometimes wonderful in Ruby and sometimes an endless source of frustration. It starts from the Liskov Substitution Principle, a famous but little-used concept in our Ruby code. As I’ve debugged dozens of apps as a Rails developer, I’ve found the LSP points to a deeper concept that’s at work in Ruby’s duck typing. So this book explores a fundamental concept of Ruby with examples of the real world code we write day-to-day in Ruby and Rails. It’s not enough to understand some lofty idea, we have to know how to apply it to write better code.
By the end of it you’ll understand:
- Why single-table inheritance is fertile ground for bugs
- The three symptoms that alert you to potential LSP violations
- How other languages have special tools for reducing violations
- How to deal with “oh what the hell now” when you get NoMethodError on nil deep in a view template
- How Rails itself has to deal with with the larger concept of substitutability
- Why the nil conveniences (||, }}=, try, dig, &., etc) make our code less reliable
- How to write classes that fit together so tightly bugs can’t sneak in
I really love your writing. The types of issues you identify are pretty much the summation of why I write Ruby and not Rails. —Chris Raehke
I’d like to thank you for introducing me to the term “connascence”! What a great single word to more easily speak about a very important concept that until now was fuzzy in my mind. That and your three symptoms are probably my biggest takeaway from your book and will definitely be evaluating my code in light of them going forward. — Gabe Durazo
You’ll immediately get a 40 page PDF download and free updates with corrections and improvements. After purchase, it’s one click for a PDF invoice you can expense to your employer or taxes.