Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save coderjun/875049 to your computer and use it in GitHub Desktop.
Save coderjun/875049 to your computer and use it in GitHub Desktop.
RCS Syntax: Variable Declarations

Variable Declarations – Don’t Use Fully Qualified Class Names

The general rule is to use import statements and not use fully qualified class names in variable declarations when typing the variable. There are two exceptions to this:

  • Exception1: If the variable name is identical to the class name
  • Exception2: If there are two Classes with the same name
// BAD - In general do not use fully qualified classnames in variable declarations
public class MyClass
{
private var _someVariable:com.rcs.somepackage.SomeClass;
}
// EXCEPTION 1 - variable name is the same as the class name
public class MyClass
{
private var SomeIdentifier:com.rcs.somepackage.SomeIdentifier;
}
// EXCEPTION 2 - two classes with the same name
import com.somepackageone.AClass;
import com.somepackagetwo.AClass;
public class MyClass
{
private var _someVariable:com.somepackagetwo.AClass; // Be specific in your classes
}
// GOOD - We use import statements rather than importing inline
import com.rcs.somepackage.SomeClass;
public class MyClass
{
private var _someVariable:SomeClass;
}

Variable Declarations – Tightly Space your declarations

When declaring variables use tight spacing. In the example you will see an example of a loosely spaced
declaration (BAD) and a tightly spaced declaration (GOOD).

// BAD - Loosely Spaced
private var _variableName : int;
// GOOD - Tightly spaced
private var _variableName:int;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment