Add sane defaults as a technical principle, at the edge beside explicit over implicit

This commit is contained in:
2026-10-04 21:51:27 +02:00
parent 5baedb58df
commit 7146b447ab
2 changed files with 5 additions and 0 deletions
+4
View File
@@ -47,6 +47,10 @@
* Explicit over implicit.
- Avoid magic, avoid "clever" solutions, only abstract when the API can clearly describe what is happening.
- Prefer explicit, descriptive names over generic ones (`invoiceRowsService`, not `service`).
* Sane defaults, where a default serves better than an explicit ask.
- A default earns its place where most callers want the same value, a wrong guess does no harm, and the caller can see and change it: a `--help` line, a documented option. Anything else is asked for.
- Defaults live where the program meets a person: a CLI, a config file, the code that wires the program together. Below that, every value is passed in, as "Explicit over implicit" asks.
- BANNED: a library constructor that quietly loads data, reads the clock or seeds its own randomness. GOOD: the library asks for each, and its CLI fills in the shipped data, the system clock and fresh randomness unless a flag says otherwise.
* Functional core, imperative shell.
- Decisions live in pure functions, data in and data out; the shell around them performs the effects and holds no branching of its own.
- Every side effect comes from outside: output, time, randomness, network and storage are injectable, so a test runs exactly the code production runs.