Hacker News new | ask | show | jobs
by Annatar 3065 days ago
1. run the code through a debugger as soon as you finish it;

2. run the code and purposely try to break it with all the edge cases you can think of;

3. run the code as if you are an end user who knows absolutely nothing about it;

4. have your colleagues try to break your code before you commit it.

https://wiki.illumos.org/display/illumos/On+the+Quality+Deat...

https://davepacheco.github.io/se411/release/fcs-quality-all-...

1 comments

1.b. Not debugger, but a tool like valgrind or options like address and thread sanitizer.

2. And 3. Does not help when you miss the edge cases.

4. It's called code review.

And my own: run the logic through an automated theorem prover, for example Isabelle. They will instantly tell you if any invariant causes a contradiction (mistake, corner case) or it cannot deduce behaviour given prerequisites. (missing specification, probably corner case)

Since it makes you write and read the code twice and forces you to think of it as necessary conditions and invariants, that alone might help.