Hacker News new | ask | show | jobs
by mdaniel 1862 days ago
> Every if statement

... has an "else" whether it's written or not. Choose carefully whether to skip writing it, but always know it's there

I try to impress that not as much upon developers, but religiously upon folks writing requirements. Many pieces of code work just fine without the else, but the amount of bugs and rewrites due to someone either not considering "but of course it always succeeds!" or because there was an implied else scenario in their head that they just didn't bother to write down are almost innumerable.

1 comments

This, so much. Every branch or decision point in either the domain model/flowchart/spec/etc or implementation should be carefully considered. This applies doubly so to error handling. Also, try to make the code paths look like or at least be recognisable by the spec. Try to keep one mental model of what happens that the team all share.