Naming conventions 741
Naming packages
It’s common for package names to use “reverse domain” naming convention. Examples of
reverse domain names include
com.macromedia for macromedia.com, and org.yourdomain
for yourdomain.org.
Use the following guidelines when you name packages:
■ Put the prefix for a package name in all lowercase letters.
For example,
com, mx, or org.
■ Put related classes (classes with related functionality) in the same package.
■ Begin package names with a consistent prefix.
For example, you might use
com.macromedia.projectName to maintain consistency.
Another example would be
com.macromedia.docs.learnAS2.Users for the Learning
ActionScript 2.0 Reference.
■ Use a clear and self-explanatory package name.
It’s important to explain the package’s responsibilities. For example, you might have a
package named
Pentagons, which is responsible for using the Flash drawing API to draw
various kinds of pentagons in documentation examples; its name would be
com.macromedia.docs.as2.Pentagons.
■ Use mixed capitalization for compound or concatenated package names.
packageName is an example of a compound, concatenated package name. Remember to
use all lowercase letters for the prefix (com, org, and so on).
■ Do not use underscores or dollar sign characters.
Naming interfaces
Starting interface names with an uppercase “I” helps you distinguish an interface from a class.
The following interface name,
IEmployeeRecords, uses an initial uppercase letter and
concatenated words with mixed case, as follows:
interface IEmployeeRecords{}
The following conventions also apply:
■ Interface names have an uppercase first letter.
This is the same as class names.
■ Interface names are usually adjectives.
Printable is a good example.
For more information on interfaces, see Chapter 9, “Interfaces.”