There’s an amazing quote I see floating around the Internet sometimes…
“Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live”
The quote is sometimes mistakenly credited to Martin Golding in 1994.
The reality is that in 1991 John F. Woods authored it in a post to the comp.lang.c++ newsgroup. The body of his message follows:
>Mark>I was wondering why it seems that the comma operator is so rarely used.
>Mark>The only time I ever see it is in ‘for’ loops. Is it really considered
>Mark>*that* bad by the programming public at large? Any comments?
>Rob>Well, I hadn’t seen it used much either outside of the for loop, but
>Rob>in Plaugher’s latest book I discovered quite a few of the following
>Rob>constructs:
>Rob> if (condition)
>Rob> var = value, anothervar = anothervalue;
>Rob>This does away with the need for braces. I am tempted to use this myself
>Rob>unless someone has a good point agains using this style. Opinions anyone?
>Consider this:
> if (condition)
> var = value; anothervar = anothervalue;
>Only one little dot is changed, but the meaning is quite different. In other
>words, using the comma operator like that makes it harder to read:
Right.Always code as if the guy who ends up maintaining your code will be a
violent psychopath who knows where you live. Code for readability.
Amazingly, thanks to Google’s mirror of the comp.lang.c++ newsgroup, you can actually view John F. Woods’ post.
P.S. Just in case that post is removed or Google shuts down its mirror… here is a screenshot of the entire conversation.