Coding Conventions

Language Standards

In general, we try to use language-specific code conventions wherever it makes sense. General guides for .NET and Flex can be found below:

If something is not described in this guide, use the resources above to determine the correct convention. If no convention can be found, use common sense.

General Syntax Rules

Curly Brackets

Curly brackets should be placed on a separate line from the statement.

Good:

if (foo == bar)
{
   ...
}

Bad:

if (foo == bar) {
    ...
}

Spacing

Statements

Follow statement keywords (if, for, while, etc) with a space before the left parenthesis.

Good:

if (foo == bar)

Bad:

if(foo == bar)

Lists, arguments, etc

Put spaces after commas.

Examples:

  • public void !MethodName(string a, int b, int c)
  • var a = [x, y, z]
  • etc...

Variable Naming

Private Variables

Private variables should be prefixed with an underscore.

Good:

private int _myVariable;

Acronyms

Use language standard.

  • Flex: All caps (e.g. XMLSerializer)
  • .NET: First cap (e.g. XmlSerializer)

Types

Use primitive types whenever possible, unless there is a reason to use the complex type equivalent.

Commenting

Public methods should be commented if the method name does not adequately describe its function. Use your discretion. Comments should be done using language standards.

Line Lengths

We do not adhere to a strict line length limit. In most cases, you should do what the IDE suggests (Visual Studio will format it when you add a semi-colon and press enter). Use your discretion.