Naming Functions

A function's name should consist minimally of a verb, possibly followed by a noun. Examples:
int getNumber(void);

void displayResults(float data);

void getData(int &x, int &y);

float calculateArea(float length, float width);
Other formatting
  • Use white-space liberally; don't try to fit everything tightly together; space between lines; space between expressions
  • Put long comments above (or below) what you are commenting on; short comments can go to the side, especially if what your commenting is very short;
  • Use consistent commenting form, especially for lengthy comments above function definitions
  • Use indentation and align blocks of code and comments
Previous page
Next page

Back to Lesson 5 Index
Back to Outline