Spelling


Correct spelling is as much to be admired in source code comments and software documentation as in any highly literary work. A spell-checker can be very helpful when checking text documents, but is often less useful for vetting comments buried within cryptic source code lines (without proper tools, of course). So please take extra time and care to review your source code for correct spelling and grammar. You might even turn up a few program bugs along the way -- it has happened to me!

The following spelling rules and suggestions are based on American, not British, usage. Since many of our European members are more familiar with British English, we won't harp on "color" versus "colour" here and there. It's more important simply to keep the usage consistent within a single document. I've used the [Merriam-Webster Online Dictionary] (an abridged work) as my primary source of reference to resolve spelling issues for the principal reason that it tends to agree with me more often than does, say, the American Heritage Dictionary.

Most of the examples below were gathered from actual occurrences in FilterMeister documentation, postings, and code listings. If you have your own personal "pet peeves", please add them here! -Alex

































































































Information

Describe how the information stuff should be formatted.

Controls

Describe how the control definitions should be formatted.

Code

Expressions

Parentheses

Brackets

ForEveryTile():
{
    if( ctl( 0 ) )
        Info( "Control 0 is set" );
    else
    {
        Info( "Control 0 is not set" );
        return false;
    }
}

Boolean expressions

// Bad
if(((x>10) && (x<2+4*5)) || ((y==0) && do_first_row))
    // ...

// Good
if( ( x > 10 && x < 2 + ( 4 * 5 ) )
 || ( y == 0
   && do_first_row ) )
    // ...

Indenting

Ternary operator

// Bad
if( a > 10 )
    b = true;
else
    b = false;

// Better
b = a > 10? true
          : false;

// Best (because we assign Boolean values)
b = a > 10;

Variable names

There are several options available and decisions to be made:

When combined, there are a few common standards in the C/C++ world: Then there's the leading underscore thing. Some consider these to be reserved for the compiler, others (including me) like them to distinguish between normal variables and those passed in as arguments. FM has no user-defined functions yet so this issue is of no hurry.

Efficiency

// Bad
if( x > 0
 && y == 1 )
    // ...

// Good
if( y == 1
 && x > 0 )