Shopify

Focus On Behavior, Not State, for a More Maintainable Codebase - Shopify

Sep 1, 2022
Focus On Behavior, Not State, for a More Maintainable Codebase - Shopify
SummaryAI, from the source post

This post details a shift in code design philosophy from focusing on state (what an object is) to behavior (what an object does) to improve maintainability. It introduces the concept of wrapping domain objects (like 'selling plans') into new classes that expose behavior-oriented methods, rather than directly accessing internal state or database details. This approach aims to reduce coupling, prevent the leakage of internal logic, and make the codebase more resilient to future feature additions like installments or layaway. The post also discusses the need for a translation layer (e.g., an extra table) to bridge the gap between internal domain logic and reporting requirements for data teams.

More from the Code Modularity and Boundary Enforcement trail