Thread: formatting
View Single Post
Old 03-30-2003, 05:12 AM   #13 (permalink)
Travis Dane
Code Monkey
 
Travis Dane's Avatar
 
Join Date: Feb 2003
Location: Netherlands
Posts: 89
Travis Dane is on a distinguished road
Send a message via ICQ to Travis Dane
Quote:
Originally posted by JJoSA
Never use style 3

Just becase you're allowed to leave off the braces, doesn't mean you should.

It's a bad habit, and will cause you endless headaches when you're trying to figure out why something is working, only to realize that a line of code was executing because it wasn't wrapped in an if statement as thought.

You lose nothing by adding braces, and you gain ease of reading and ease of maintainence

Just Friday I spent hours debugging a piece of code, and one of the main problems was exactly this... a coworker left braces off. Combine that with poor (IE no) indentation in the script and it was damn near impossible to stop

Trust me, I've been doing this 20+ years. Don'e leave the braces off
I have never had the problem of forgetting braces, Never.
Adding braces causes big and ugly code, If you have a problem
with forgetting braces with multiple statements than blame that
and not the braces.
__________________
OpenGL, DirectX
Travis Dane is offline   Reply With Quote