Sign in to follow this  
armond

The type convention thing...

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this