The following guidelines apply to naming classes:
Begin a class name with an uppercase letter.
Write class names in mixed case when it's a compound or concatenated word.
Begin with an uppercase letter for a compound or concatenated word. A good example is
.
NewMember
Class names are usually nouns or qualified nouns.
A qualifier describes the noun or phrase. For example, instead of "member," you might
qualify the noun by using
Clear names are more important than short names.
Don't use acronyms and abbreviations.
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
Use meaningful and simple names that are descriptive of the class contents.
To avoid being vague or misleading, use generic names.
Sometimes a class name is a compound word.
A qualifier might describe the noun or phrase. For example, instead of "member," you
might qualify the noun using
Do not pluralize the words you use in the class name (such as
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
Don't use a class name in the properties of that class because it causes redundancy.
For example, it does not make sense to have
much better.
Don't use nouns that also might be interpreted as verbs.
For example,
Running
methods, states, or other application activities.
Use unique class names for each class in a single application.
Do not name classes so that they conflict with the names of built-in classes in Flash.
Try to communicate the relationship that a class has within a hierarchy.
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
740
Best Practices and Coding Conventions for ActionScript 2.0
or
NewMember
instead of
NewHTMLParser
NewMember
or
BlackCat
OldBuckaneer
, or
. Using these nouns might lead to confusion with
Gardening
Chapter 9, "Interfaces."
.
OldMember
for improved readability.
or
.
OldMember
.
Cat.catWhiskers
or
Witches
BaldPirates
. Instead,
Cat.whiskers
).
is
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?