Programming

From IndieGuide

Jump to: navigation, search

Contents

Programming Languages

Each language is dealt with on another page:

General Programming Tips

Bear some of these things in mind when programming.

  • Check what the CPU load of your game is. When the game is idle, it's poor programming to have a CPU load of 50% or 100%. Open the task manager, and it it will show you the CPU load.
  • Check your memory usage. Avoid memory leaks at all costs (forgetting about freeing used memory). The task manager also helps you with this.

Style Guides

Inline Documentation / Comments in source code

The best way to document software (for a programmer) is by writing readable code (opposed to complicated and optimised to the degree that even the programmer himself can't figure out how it works). However, some documentation embedded in the source code, so called "inline documentation" or just "comments" helps a lot to structure source code. This kind of documentation is not only restricted to comments in the functions but also to header for the function or the file.

However, beware not to overcomment. If there are more comments than code, then something went wrong. The comments shouldn't obstruct the flow of the code either.

Reasons for comments

There are benefits from using comments:

  • You put relevant information where you need it - this helps in the future when you come back to change or extend functions.
  • It helps to structure the source code.
    • Function headers help separate different functions in one file.
  • It helps other programmers, should they use your code (e.g. for open-source or joint projects).
  • There are tools that can extract comments and automatically create documentation.

Automatic documentation generation

There are tools that allow the extraction of inline documentation plus their structure of the files/classes from the source code.

Tools:

  • xxx

Examples in C/C++

The header for a file:

/*
*
*
*
*
*/

The header for a function:

/*========================================================
 * Name:        createXXX
 * Description: This function creates ....
 * Parameters:
 *              x - contains the number of ....
 *              y - contains the number of ....
 * Return:      none
 * Created:     John Doe, 15th April 2008
 * History:
 *              John Doe, 15th April 2008: added a new variable that ...
 *======================================================== */

The header for a class:

/*
*
*
*
*
*/

Personal tools
Advertisement