Coding Standards
When you write programs , there are some important
stylistic things that you should do to make your program
clear and well-structured.
Below is a list of these requirements:
-
Check the return value of all system or library calls.
-
There should be no more than one class per file.
-
For non-template classes, the interface definition part of the class should
be in a .h file and the implementation of the methods should be in a .C (or .cc)
file.
-
Always indent when statements are part of a control-flow statement
such as "if" or "while".
Choose a reasonable number of characters (such as 3 or 4) and make
sure that you indent consistently.
-
There should be constants other than, perhaps, zero or one, in your
code.
Any constant values should preferably be defined as using a "const"
declaration or.
-
Public data members are a really bad idea, in general.
If you think that you need one, please come and talk with Me.
They are not acceptable in your program without prior permission.
-
Comments:
- Each file should have a comment at the top with at least the
authors' names
- Each function or method should have a comment at the beginning
summarizing what it does and, if it is not obvious, how it does
it.
- For long functions or method, you should include a comment
at reasonable intervals. The intervals should break the
function into logical chunks. The comment should summarize
what the chunk does.
-
You must use a "makefile" for your program. The default rule should
build the whole program.
-
You can use any class and method in the Standard Template Library (STL).