Jump to content
  • Advertisement
Sign in to follow this  
Nene

Indent styles

This topic is 3408 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I've been reading about indenting styles and I have one question about the Allman/BSD style:
class ClassName
{
   ...
};
void functionName( ... )
{
   ...
};




It is so common and may be found in the MSVC++, Windows SDK and DirectX, as well as a lot of other sources. It is also used in combination with the K&R style for classes, structs, etc. except for control structures like if, while, etc.
void functionName( ... )
{
   struct StructName
   {
      ...
   };
   if( ... ) {  // K&R style
      while( ... ) {
         ...
      }
   }
};




It is the recommended style in many guidelines: http://www.gamedev.net/reference/articles/article708.asp http://geosoft.no/development/cppstyle.html ... However, in the book "Code Complete 2nd ed" states that this style breaks the logical structure of the code, and a pure K&R or the Whitesmiths style (I personally dislike it) are better. What do you think guys? I still think that placing the braces in another line in classes, structs, enums, functions... and placing it on the same line for if, switch, while, for... looks much better. Also, I'm wondering what to do with namespaces. Since all my engine is placed within the same one, I have to indent the whole code in almost every header, like this:
namespace name
{
   // All definitions intended
}




What would you do? Thank you a lot!!! :)

Share this post


Link to post
Share on other sites
Advertisement
There's been a lot of past discussion of coding styles in this forum... a google search should turn up plenty of info.

Share this post


Link to post
Share on other sites

This topic is 3408 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!