Where to put curly braces

Code formatting is clearly something personal.

Some prefer code without blank lines, others like when the code is grouped in blocks separated with blank lines.
I belong in the second team.
A common talk with colleagues is where to put curly braces ?

Without any blank line, you have the following code :
Loading ....

I agree that identifying code blocks is not immediate. That's why, I often see this code format :
Loading ....
Now, you can see the two blocks very quickly.
But, the Java specification says that curly braces should be at the end of the line ! So the previous code breaks this rule. To solve this, just add a blank line before a block, like that :
Loading ....
Now, you can still identify blocks quickly, and your curly braces are correctly placed.

Commentaires

Posts les plus consultés de ce blog

Reminder : Mdadm commands

Easily create your own Eclipse

Calendrier google des jours fériés