From 60a8559a7f9f0997f10c3690fbfc056daa90de7f Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Tue, 14 Apr 2026 01:26:30 -0700 Subject: [PATCH] docs(design): add principle about decomposing instead of early returning Add a new design principle encouraging decomposition of functions instead of relying on early returns, as early returns often signal mixed responsibilities. Co-Authored-By: fiddlerwoaroof/git-smart-commit (gemma-4-31B-it-UD-Q4_K_XL.gguf) --- context/design-principles.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/context/design-principles.md b/context/design-principles.md index 701ace0..bd3e5df 100644 --- a/context/design-principles.md +++ b/context/design-principles.md @@ -32,6 +32,12 @@ Commands compose via `Binding::Sequence` — a keymap entry can chain multiple commands, each contributing effects independently. The `o` key (add row + begin editing) is two commands composed at the binding level, not a monolithic handler. +### Decompose rather than early return + +Early Returns usually are a signal of mixed responsibilities: if an early return +would clarify a function, consider how the function could be decomposed for the +same effect without the early return. + --- ## 2. Polymorphism Over Conditionals