you are viewing a single comment's thread
view the rest of the comments
[–] 8 points 2 years ago* (1 child)

P1000x this.

I can read a diff.

I need to know why.

No, a code comment isn't good enough, it's out of date after the next commit.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 2 years ago (1 child)

    Code comments for "why"s that persist. Commits for why's that are temporary.

    If you need to run X before Y, add a comment. If you added X before why because it was easier, leave it in a commit

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago (1 child)

    If you need to run X before Y...

    Add a test that asserts that.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 2 years ago

    With a comment on the test detailing why it matters so people don't just assume the test is out of date when it fails.

    And ideally test the underlying result of x before y, not the fact that x is called before y.

    And while we're at it, assert in Y that X has been called, and again comment the reason for the preconditions.

  • source
  • parent