Why code flexibility should sometimes override domain model constraints in software design
By
zdw
Pulled from the oven just right. Trustworthy, fact-dense, deeply satisfying.
Summary
The article argues against the popular software design principle "make invalid states unrepresentable," which advocates tightly binding code to domain models. The author contends that code should be more flexible than the domain model, allowing for evolution and adaptation. The principle typically involves enforcing single sources of truth in database schemas and using type systems to prevent illegal states. The author presents a controversial counter-perspective that rigid domain binding can lead to brittle, hard-to-change systems, and advocates for looser coupling between code and domain representations.
Key quotes
· 3 pulledOne of the most controversial things I believe about good software design is that your code should be more flexible than your domain model.
This is in direct opposition to a lot of popular design advice, which is all about binding your code to your domain model as tightly as possible.
A popular principle for good software design is to make invalid states unrepresentable.
You might also wanna read
Optimizing .NET APIs for High Throughput: Techniques for 1M Requests Per Minute
Article discusses techniques for designing high-throughput .NET APIs capable of handling 1M requests per minute. It covers horizontal scalin
SQLite as a Viable Alternative for Durable Workflow Execution
The article argues that SQLite can replace complex orchestration systems for durable workflow execution in many cases. It builds on DBOS's a
JWT vs Opaque Tokens: A Technical Comparison for API Security Architecture
This article compares JWT (JSON Web Tokens) and opaque tokens for API security, clarifying the common confusion between bearer tokens and JW
How Frontend State Management Becomes a Distributed Monolith as Apps Scale
This article discusses how frontend state management in growing applications can evolve into a "distributed monolith" — where state becomes
A Field Guide to Production-Ready AI Agents: Context Windows, Security, and Drift Monitoring
Karl Mehta presents a field guide for building production-ready AI agents, focusing on four key engineering challenges: context-window disci
The Convergent Architecture of Frontier Agentic Systems
This article from Veso Research analyzes the emerging universal architecture across frontier agentic systems (Claude Code, OpenAI Codex, Gem
