• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Curious, Healing

Curious, Healing

Books about healing, business, and fun

  • About Sonia Connolly

“Practical Object-Oriented Design in Ruby” by Sandi Metz

February 19, 2022 by Sonia Connolly Leave a Comment

book cover

Subtitle: An Agile Primer

Recommended to me by: Sam Livingston-Gray

I first read this back in 2012. It struck me as friendly rather than condescending this time, which is an interesting shift.

In 2012 I was just learning Ruby and focused on deciphering the example code as I read. Coming back to it after having programmed in Ruby for three years, I could read the examples fluently and focus more on the general points in the book, even though I haven’t looked at Ruby code in a while.

Some points that stuck with me this time:

  • The purpose of design is to allow future changes in code, since requirements and circumstances keep changing.
  • In object-oriented design, pay attention to the messages passing between the objects.
  • Each object should have a single responsibility. (I’ve seen a downside to this, where you have to chase through a mass of fine-grained objects to find where something is actually done.)
  • Manage dependencies to reduce risk. An object should depend on objects that change less often than it does.
  • Inject dependencies, use Ruby’s duck typing: Send in an object as an argument that responds to the needed message
  • Delay design decisions until you have at least three examples of what a class needs to do. (Two, if pressed.)
  • Good design is TRUE: Transparent, Reasonable, Usable, Exemplary
  • DRY: Don’t Repeat Yourself.
  • Law of Demeter: Don’t chain calls through many objects, since that entails knowing too much about the insides of other objects.
  • Isolate risky bits of code inside a wrapper, so they can be improved easily later.
  • Test an object’s public interface (messages it responds to), and command messages it sends (messages with side effects).
  • Use Ruby Modules to share code and tests.

Highly recommended as a guide for both general design, and how to write maintainable, flexible Ruby code.

The book’s website and Sandi Metz’s website.

Available at bookshop.org.

Filed Under: nonfiction Tagged With: software

Reader Interactions

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Recent Books

  • “Very Far Away From Anywhere Else” by Ursula K Le Guin
  • “Seaward” by Susan Cooper
  • “Surviving Domestic Violence” by Elaine Weiss
  • “The Book of Love” by Kelly Link
  • “Alexandra’s Riddle” by Elisa Keyston
  • “Weaving Hope” by Celia Lake
  • “The Fortunate Fall” by Cameron Reed
  • “Remarkably Bright Creatures” by Shelby Van Pelt
  • “Childhood’s End” by Arthur C. Clarke
  • “If the Buddha Married” by Charlotte Kasl, Ph.D.

Tags

activism aging anti-racism bodywork business childhood abuse childrens CivicTech communication disability domestic violence fantasy feminism finance Focusing food fun healing health at any size illustrated Judaism leadership lgbt marketing memoir music natural world neurodiversity politics psychology relationship romance science science fiction software spirituality survival story trauma writing young adult

Categories

Archives

Please note: bookshop.org and Amazon links are affiliate links. Copyright © 2025 · Genesis Sample on · WordPress