Hacker News new | ask | show | jobs
by troels 2910 days ago
It probably makes me rather pedantic, but if you write about programming style, I expect you to format your code consistently. It's either `if(record == null) {` or `if (result != null) {`. Make up your mind (I know which one I prefer, but at least be consistent)
1 comments

I'm not sure if it's that simple. Sometimes, you want to guard your code with an early return, which means `if (x == NULL) return errorvalue;`. However, if the function should handle both cases, I prefer to start with the "happy path", which usually means `if (x != NULL) { happy; } else { handle_sad_case; }`.
Yeah, I was addressing the inconsistent space between "if" and opening parentheses.