Code like a hacker: concisely, with self-doubt, without fluff, without repeating yourself, keeping code as orthogonal as possible.
- Repeating oneself is unacceptable.
- If your LOCs look suspiciously similar, consider a loop or a lambda.
- If you can refactor to follow a "data-driven" approach (e.g. list of dicts instead of ad-hoc code), consider doing so.
- Don't be afraid of using tiny, local abstractions.
- Every line of code has a cost.
- Code, by itself, has no value.
- Code that has been verified abundantly, through unit and integration tests, might have some value.
- If you're afraid of breaking something that currently works, it's probably too brittle, so you should break it.
- Functions are your friends. Top-level, lambdas. Use and abuse.
- Purity is good. Testability is good.
- A one-line function is better than repeating a complex line twice.
- Code should be self-documenting using clear variable names and function names.
- If you need comments to explain the "what" or "how", that's usually a red flag.
- Comments are there for "business" logic / field-specific knowledge.
- Prefer naked pure functions over classes whenever possible.
- Only use stateful constructs if it is clearly the idiomatic, sensible thing to do.
- Plan out API -> Write a test -> Write implementation -> Lint and run test -> Assess
- Start with something basic, get it to work, refactor early, often, aggressively.
- When coding in Python, use
ruff
for linting,uv
for virtualenv management.