Flash CS3 Documentation |
|||
| Learning ActionScript 2.0 in Adobe Flash > Best Practices and Coding Conventions for ActionScript 2.0 > Naming conventions > Naming classes and objects | |||
When you create a new class file, use the following guidelines when you name the class and ActionScript file. For proper formatting, see the following examples of class names:
class Widget; class PlasticWidget; class StreamingVideo;
You might have public and private member variables in a class. The class can contain variables that you do not want users to set or access directly. Make these variables private and allow users to access the values only by using getter/setter methods.
The following guidelines apply to naming classes:
Begin with an uppercase letter for a compound or concatenated word. A good example is NewMember.
A qualifier describes the noun or phrase. For example, instead of "member," you might qualify the noun by using NewMember or OldMember.
The exception to this rule is if acronyms or abbreviations represent the standard way to use a term (such as HTML or CFM). For commonly used acronyms, use mixed cases such as NewHtmlParser instead of NewHTMLParser for improved readability.
To avoid being vague or misleading, use generic names.
A qualifier might describe the noun or phrase. For example, instead of "member," you might qualify the noun using NewMember or OldMember.
Witches or BaldPirates). In most cases, it is better to leave the words as qualified nouns instead. A qualifier describes the noun or phrase. For example, instead of "cat" or "buckaneer," you might qualify the noun by using BlackCat or OldBuckaneer.
For example, it does not make sense to have Cat.catWhiskers. Instead, Cat.whiskers is much better.
For example, Running, or Gardening. Using these nouns might lead to confusion with methods, states, or other application activities.
This helps display a class's relationship within an application. For example, you might have the Widget interface, and the implementation of Widget might be PlasticWidget, SteelWidget, and SmallWidget.
For information on interfaces, see Interfaces.
Flash CS3