9.24.2008

Code Recommendations

A few recommendations after developing my first Flex app:

1) Use "as" instead of "()" to cast objects. This provides consistent syntax for all casting (Date and Array require "as") and cannot be misinterpreted as a constructor call.

2) Use a "prop" suffix instead of "_" prefix for properties. This reduces the visual noise and doesn't resemble bad Java/C++ practices.

3) Use properties for members that are externally accessible, use simple members for internal access. Use the actual property name (not the internal name with suffix) when referenced within the class.

4) Always provide a default constructor. If more construction options are needed provide factory methods.

5) Avoid MXML as much as possible. It makes the code messy and provides little added benefit. It also forces the developer to constantly make decisions about whether to implement features in MXML and ActionScript and forces the developer to learn how to implement in both languages. Instead provide a standard container with helper methods that make it easy to create pure ActionScript components.

6) ActionScript is very flexible and has many interesting nooks and crannies. To simplify development some features should be avoided if possible. These include: dynamic classes, definitions outside classes or interfaces, untyped properties, namespaces in ActionScript. Also always compile using strict dialect.