RoboCup Coding Style

From GT RoboJackets

Jump to: navigation, search

These are the RoboCup Coding style guidelines for the software. They are here as a guide and following them is encouraged in order to maintain the sanity of the other coders that have to read your code. A Source and Header file are provided as an example.

Style Guidelines

  • Use tabs instead of spaces at the start of lines (indentation).
  • Use spaces after defines and where textual appearance is important.
  • All brackets should be on their own line. Closing brackets can have text after them ( i.e. } while ...; )
  • Once an opening bracket has been used the indention level increases. A closing tab decreases the tab level.

Header File

Name: ClassName.hpp

#ifndef CLASSNAME_HPP
#define CLASSNAME_HPP

#include <system includes>

#include "user includes"

/* All indentation is with a TAB character unless a certain formatting 
 * layout is desired, in which case spaces will be used to preserve 
 * appearence. */

/* Comments for classes, methods, types, and members should follow doxygen 
 * style commenting if needed. Minimal description commenting is advised */

namespace NamespaceName
{
	/** Class comment */
	class ClassName
	{
		/// Types
		public:
			/** Type comment */
			typedef enum
			{
				EnumVal1,
				EnumVal2
			} EnumName;
		
		protected:
			typedef struct
			{
				int structMember;
			} StructName;
		
		private:
		
		/// Methods
		public:
			ClassName(...);
			ClassName(ClassName& cpy);
			~ClassName();

			/** Method comment (doxygen style) */
			void memberMethod(...);

			static void staticMemberMethod(...);

			/** _character accessor */
			char character() const { return _character; }
			/** _character mutator */
			void character(char newCharacter) { _character = newCharacter; }
			
		protected:
		private:
		
		/// Members
		public:
			static int staticMemberName;
		
		protected:
		private:
			/** Comment */
			int _memberName;
			
			/** Comment */
			char _character;
	};
}

#endif /* CLASSNAME_HPP */

Source File

Name: ClassName.cpp

#include "ClassName.hpp"

#include <system includes>

#include "user includes"

using ...

///static member declarations here

ClassName::ClassName(...)
{
	if (...)
	{

	}
	else [if (...)]
	{

	}
	// <-- mandatory blank line after if blocks
	if ()
	{
	}
}

ClassName::~ClassName()
{
	
}

void ClassName::memberMethod(...)
{
	
}

...


Personal tools