Writing Code

  • The moment you write code, it is already technical debt.

  • Every new line of code is an investment

    • How do you manage your investment?

Goals for writing code

Balance writing for longevity.

  • How long will your code last?

Write for clarity.

Write for simplicity.

  • For the long term: simplicity out lives complexity.

Write knowing that it will be read later.

More time will be spent reading and understanding code, than writing it. Reading to writing ratio is really high.

Write so that it is easy to understand.

Write to reduce "WTFs/minute". source: WTFs/minute is the only valid measurement of code quality‚Äč

Write with the aim to reduce surprises.

Write code that is easy to test and reproduce.

Write code that is meant to be read, and not meant to solve a problem.

Don't write complex code. Write simple code.

Becareful of death by a thousand cuts/commits/diffs. It is very easy to lose track of the architecture.

Reduce create technical debt.

See Reviewing Code.

What is clarity?

  • Easy to read

  • Consistency

  • Naming

  • Conventions

  • Trust

Goals:

  • Increase signal. Reduce noise.

  • Reduce petty philsophical disagreements. Avoid bike shed problems.

  • Save time, energy and resources for the larger technical problems.

Examples:

  • You should not be wasting time, energy, and resource discussing style. Quickly come to an agreement and stick with it. Use a linter. Don't increase noise.