Naming conventions 739
Naming functions and methods
Use the following guidelines when you name functions and methods in your code. For
information on writing functions and methods, see Chapter 6, “Functions and Methods.”
■ Use descriptive names.
■ Use mixed case for concatenated words.
A good example would be
singLoud().
■ Start function and method names with a lowercase letter.
■ Describe what value is being returned in the function’s name.
For example, if you are returning the name of a song title, you might name the function
getCurrentSong().
■ Establish a naming standard for relating similar functions.
ActionScript 2.0 does not permit overloading. In the context of object-oriented
programming, overloading refers to the ability to make your functions behave differently
depending on which data types are passed into them.
■ Name methods as verbs.
You might concatenate the name, but it should contain a verb. You use verbs for most
methods because they perform an operation on an object.
Examples of method names include the following:
sing();
boogie();
singLoud();
danceFast();
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.