Monday, September 20, 2010

In Java always use braces

Warning: Python programmers must NOT read this post.

This is funny: from Standford Java course professor Mehram Sahami
In Java programming follow the rule of orthodontist:
"You need braces"
Orthodontist will always say this to EVERY patient!

What he means is: don't write a shorthand "no braces" code blocks,
like these:
if(num % 2 == 0)
println ('num is even');

always use braces:
if(num % 2 == 0){
println ('num is even');
}

It's just easier for another programmer to read.

No comments:

Post a Comment