You are here: Recent News » Projects » ActionStep » Guidelines

 

Guidelines

Use Tab’s rather then Spaces for white space. Rationale - individuals can then tailor their editing environment to to set whatever number of spaces they like for each tab.

Always use braces around block statements, even if it is a single statement.

Example of good code:

if(!true) {
    dosomething();
}

Example of bad code:

if(!true) dosomething();

Another example of bad code:

if(!true) 
	dosomething();

Always use public and private for all variable and function definitions. These must come first, before static, if the var/function is static.


All member variables are prefaced with m_ and class variables with g_.


All default values for member variables should be set in the constructor.

// Constants
public static var NSRunContinuesResponse:Number = -1002;
// Private Static
private static var g_init:Boolean;
//Private
private var m_active:Boolean;
 
public function Class(active:Boolean) {
	this.m_active = active;
}

Never use static initializers (or inline static variable assignments) that refer to another ActionStep class. We can’t be sure about order in which classes are registered, and we”ve run into issues where weird things happen.

Example of good code:

class MyClass {
	private static var g_app:NSApplication;
 
	public function Class() {
		if (g_app == undefined)
			g_app = NSApplication.sharedApplication();
		}
	}
	//...
}

Example of bad code:

class MyClass {
	private static var g_app:NSApplication = NSApplication.sharedApplication();
	//...
}

Limit the number of characters to 80 per line. Long lines are hard to read, as the reader has to scroll back and forth.


If you need to use a “header” or “region”, 54 asterisks is fine.

For example:

  //******************************************************                               
  //*           Editing and selecting cell text
  //******************************************************

NOTE - these guidelines need to be arrived at and built by consensus. Please join the mailing list to participate in the discussion

projects/actionstep/coding_standards.txt · Last modified: 2007/02/19 08:12 by niko