Code Katas
Short, deliberate-practice drills. Each kata is 15-25 minutes. Repeat until fluent. Pick any one of your working languages; switch languages between repetitions to notice where patterns collapse.
How to Use
- Set a timer.
- Write only what the kata asks. Resist adding "extra" patterns.
- After the timer, spend five minutes writing the functional or plain-composition version of the same solution and compare.
- Log one lesson per repetition.
Kata 1: Builder for HTTP Request
Skill targeted: Builder, immutability, end-of-process invariants. Time limit: 20 minutes.
Build an HttpRequest value type with a fluent Builder:
- required:
url,method - optional:
headers(map),body(bytes),timeout(Duration, default 30s) - invariants checked in
build():urlis non-null and starts withhttp://orhttps://- if
method == "GET",bodymust be null timeout > 0
Acceptance:
- the built request is immutable
- the call site reads like a recipe
- exactly one test per invariant, failing with a clear message