Variables... uppercase... merrrrrr

Started by
9 comments, last by jbadams 12 years, 7 months ago

[quote name='ApochPiQ' timestamp='1315593962' post='4859691']
This is part of working with other people's code.

I prefer the Correct Bracing Style in curly-braces-oriented languages:
[...]
However, it is also popular to use the Incorrect Bracing Style:
[...]

Can you explain why option 1 is the "correct bracing style" ?
[/quote]
He was being facetious -- neither is "correct" or "incorrect", but programmers will often claim that whichever method they personally prefer is "correct", and may even have a string of reasons they believe this to be true -- you can see a similar reference in Telgin's reply, where he refers to "The One True Brace Style".

As has already been noted the important thing is to choose a style and to apply it consistently, or if you're working in a professional environment to consistently and correctly follow any guidelines provided by your organisation. Even if there aren't guidelines provided, if you're working with an existing body of code it's usually easier to stick with the conventions already in use.

Your bracing style is fine for your own projects or where it matches the style already in use -- the only approach that is really Wrong™ is to mix different styles rather than being consistent -- and then we only say it's Wrong™ because it's likely to make your code harder to read and maintain; it won't cause compile errors or anything, and if you really want to you can be as inconsistent as you like in your personal projects, it's just likely to end up biting you in the ass down the road, and no good programmer would recommend it.

- Jason Astle-Adams

This topic is closed to new replies.

Advertisement