Visual summary of operating lessons from Sandi Metz.

Lessons from Sandi Metz

The items below are lines from four blog posts Sandi Metz wrote about abstraction, object-oriented design, complexity and code style. — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.

Part 1: The Cost of Abstraction and Duplication

  1. On Going Back: In “The Wrong Abstraction,” Metz wrote: "When dealing with the wrong abstraction, the fastest way forward is back". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.
  2. On Inlining: In “The Wrong Abstraction,” Metz wrote: "Re-introduce duplication by inlining the abstracted code back into every caller". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.
  3. On Parameters and Conditionals: In “The Wrong Abstraction,” Metz wrote: "If you find yourself passing parameters and adding conditional paths through shared code, the abstraction is incorrect". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.
  4. On Letting Duplication Show You: In “The Wrong Abstraction,” Metz wrote: "Once an abstraction is proved wrong the best strategy is to re-introduce duplication and let it show you what's right". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.
  5. On Preserving Effort: In “The Wrong Abstraction,” Metz wrote: "We know that code represents effort expended, and we are very motivated to preserve the value of this effort". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.
  6. On Presence as Proof: In “The Wrong Abstraction,” Metz wrote: "Its very presence argues that it is both correct and necessary". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.
  7. On Advancing: In “The Wrong Abstraction,” Metz wrote: "This is not retreat, it's advance in a better direction". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.
  8. On Hard Feature Work: In “The Wrong Abstraction,” Metz wrote: "Adding new features was incredibly hard, and each success further complicated the code, which made adding the next feature even harder". — Sandi Metz, “The Wrong Abstraction”, sandimetz.com.

Part 2: Object-Oriented Design and Messages

  1. On Enabling Ways of Thinking: In “What Does OO Afford?,” Metz wrote: "programming languages are explicitly designed to “enable” certain kinds of thinking". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.
  2. On Roles and Messages: In “What Does OO Afford?,” Metz wrote: "you clearly have to know what messages you can send, but you don't need to know anything about what happens “over there” where the message is received". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.
  3. On Loose Coupling: In “What Does OO Afford?,” Metz wrote: "The next idea to add to your OO mindset is loose-coupling". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.
  4. On Tight Coupling to a Role: In “What Does OO Afford?,” Metz wrote: "Tight-coupling to a role not only forces you to know many different class names, it also requires that you know how to select the correct one". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.
  5. On Factories: In “What Does OO Afford?,” Metz wrote: "If creating the right object requires a conditional, this should happen in a “factory.”". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.
  6. On What OO Affords: In “What Does OO Afford?,” Metz wrote: "Here again is what OO affords: anthropomorphic, polymorphic, loosely-coupled, role-playing, factory-created objects that communicate by sending messages". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.
  7. On Incomplete Affordances: In “What Does OO Afford?,” Metz wrote: "The need for a sign suggests that the design of the hardware fails to offer a complete set of affordances". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.
  8. On Conveying Use: In “What Does OO Afford?,” Metz wrote: "The styles above convey all of the information you need to use them correctly". — Sandi Metz, “What Does OO Afford?”, sandimetz.com.

Part 4: Managing Changeability

  1. On Never Designing: In “Breaking Up the Behemoth,” Metz wrote: "If you never do design, your code will become a painful mess". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.
  2. On OO Versus Procedures: In “Breaking Up the Behemoth,” Metz wrote: "Relative to complex procedures, OO is easier to understand and change". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.
  3. On Simple Procedures: In “Breaking Up the Behemoth,” Metz wrote: "For some problems, simple, non-conditional, non-duplicated procedural code is the best solution". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.
  4. On Design With Every Request: In “Breaking Up the Behemoth,” Metz wrote: "Use every new request as an opportunity to do a bit of design". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.
  5. On Small Innocent Changes: In “Breaking Up the Behemoth,” Metz wrote: "A series of small, innocent changes turned the application's most important code into a class so complex that no one could fix it". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.
  6. On Important Procedures: In “Breaking Up the Behemoth,” Metz wrote: "The procedures that are important to your domain increase in complexity faster than other code". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.
  7. On Converting Complex Procedures: In “Breaking Up the Behemoth,” Metz wrote: "Extremely complex procedures are more difficult to convert to OO". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.
  8. On Obscured Details: In “Breaking Up the Behemoth,” Metz wrote: "Another consequence of message sending is that it obscures the details of what happens as a result". — Sandi Metz, “Breaking Up the Behemoth”, sandimetz.com.

Part 8: Architecture and Mindset

  1. On Reading Cost: In “Why We Argue (Style),” Metz wrote: "Code is read many more times than it is written, which means that the ultimate cost of code is in its reading". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  2. On Agreeing on Style: In “Why We Argue (Style),” Metz wrote: "It's easy for a group of programmers to agree that all code should follow a common style, but surprisingly difficult to get them to agree on just what that common style should be". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  3. On Style Guides: In “Why We Argue (Style),” Metz wrote: "Choosing a style guide means building agreements in areas where we have strong differences of opinion about issues of little significance". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  4. On Compromise: In “Why We Argue (Style),” Metz wrote: "Most guides please and disappoint in equal measure, and so require compromises from all". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  5. On Outsourcing the Guide: In “Why We Argue (Style),” Metz wrote: "If you're in a shop with a history of conflict, it's best to outsource the guide". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  6. On Automatic Enforcement: In “Why We Argue (Style),” Metz wrote: "The easiest way to enforce this is to put automatic processes in place to alert folks to violations in their own code". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  7. On Supplying Information: In “Why We Argue (Style),” Metz wrote: "supply programmers with the information they need to remedy their own transgressions". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  8. On Pull Request Conversations: In “Why We Argue (Style),” Metz wrote: "Pull request conversations ought to be about what code does rather than how code looks". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.
  9. On Stable Code: In “Why We Argue (Style),” Metz wrote: "Don't bother updating the styling of stable, existing code unless not doing so costs you money". — Sandi Metz, “Why We Argue (Style)”, sandimetz.com.