The type convention thing...

Started by
5 comments, last by Yann L 18 years, 4 months ago
Hi, I'm used to doing if (condition) { //statement here } while many are used to if (condition){ //statement here } I find the first one to be more readable... However, the latter seems to be the standard for almost every programmer (Even authors of some books). If you're working alone, this would not be a big issue... But if you're working in a team... This could give you a bit of a headache especially when trying to debug otehr people's code... What do you prefer? Why are so many people using the latter?
We should never stop learning...
Advertisement
Authors tend to use the latter version because you can fit more lines of code on the page. Though I personally prefer to use it in my code. But a professional programmer can easily read and write both versions. It's really not that big of a deal.
First, I don't see how your title has anything to do with the topic. Second, this doesn't really belong in the game development forum.

For the most part, it doesn't matter what brace style you use. If you work in a team, you should make a standard and have all of the members obey it, for consistency and readablity.
I prefer the former; it's easier to keep track of many levels of braces and looks a lot cleaner. People probably use the latter because it's K&R style.
Ra
Well if you were working in a large scale team, full of programmers, then to any professional the difference in syntax style would make little difference. If i was to guess, the reason why more people use the 2nd syntax rather than the first is because most books use teh latter and people copy the style.

Dave
I prefer the second [as long as the block in the braces is indented]. To me, the brace is part of the conditional, and thus belongs on the same line. Just like the close brace for a do{}while(); goes on the same line as the while.
If you work in a professional team, then the source formating and naming conventions are determined by the company, and everybody on the team has to follow them, regardless of personal preference. This ensures consistency and code maintenability.

On personal projects, don't worry about it and use whatever you prefer.

This topic is closed to new replies.

Advertisement