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)
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user