aboutsummaryrefslogtreecommitdiff
path: root/notes/cognitive_load.txt
blob: 21cc3e41b842bd4099cf2ee822fcb280bff171fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Try to keep minimal "cognitive load" at all times.

* Minimize "symbol density"
  I.e. the number of symbols in a function body required to do some
  specific task.
  This *excludes* things that decrease cognitive load, such as:
  types, pre-conditions, assertions, etc.
* Minimize states
* Minimize "control-flow state" and control-statement nesting
  This is basically the number of bblocks.
  This can be done by transforming:
  - trivial loops into trivial functional expressions
  - nested blocks into non-nested blocks, e.g.
    `if A; B; end` into e.g. `only A; B`
* Minimize possible states per line.
  - Avoid boolean variables, use control flow instead.
  - Avoid mutability
  - Use `given` to avoid introducing variables
* Prefer local context over global context
  - Use `given` "statement prefixes" rather than extra variables