'Make invalid states unrepresentable' considered harmful
3 days ago
- #flexibility
- #software-design
- #constraints
- The article argues against the principle of making invalid states unrepresentable in software design, advocating for more flexibility.
- It suggests that real-world software needs to handle edge cases and exceptions, making overly strict constraints harmful.
- Examples include state machines, where allowing arbitrary state transitions can be necessary despite complicating the design.
- Foreign key constraints in databases are critiqued for reducing flexibility, especially in large-scale applications.
- Protocol Buffers' removal of required fields is highlighted as a positive move for easier schema changes.
- The author emphasizes that domain models are not real and that software should tolerate some invalid states to remain adaptable.
- Constraints are not entirely bad but should be balanced to avoid making the system too rigid to change.