Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I worked at a company a ways back that had a very strict rule about always putting braces on conditionals. This was because at one point an engineer changed a one-line conditional to a two-line conditional and forgot his braces. It was a fairly minor condition, and it slipped through testing. It ended up being responsible for a very quick $5M in lost revenue before it was caught and the code was rolled back.

Of course there are some better practices that would have caught it, but it was an easy mistake to make and an easy mistake to miss.

Another one I've come to enjoy is Java's insistence that I only provide booleans to my conditionals. It is a bit onerous to write "== NULL" a lot, but there have also been many times in C I accidentally forgot that the function I was calling did not return a boolean and so my test didn't do what I thought it would. For example, memcmp is not a true/false function but a negative/zero/positive function and so if you do not check "== 0" you can easily invert your logic.



Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: