Showing posts with label AS3 OOPS Naming Convention. Show all posts
Showing posts with label AS3 OOPS Naming Convention. Show all posts

Monday, March 8, 2010

AS3 Naming Conventions

Use precise, meaningful, contextually relevant names that are as descriptive as possible. Limit the use of unnecessary abbreviations.

Example: defaultImagePreview
NOT: dfltImgPrv


Start each instance name with a lowercase letter, and intercap the remaining words.

Examples: menuItem, sectionTitle

Apply the same conventions to variable names.

Examples: accountNumber, startingPoint, currentProductName

Begin a class name with an uppercase letter. Write class names in mixed case when it’s a compound or concatenated word. Keep package names as short as possible, using reverse domain naming conventions.

Examples: com.client.project.component.ClassName

Name functions and methods in the form of verbs, since they perform actions.

Examples: getUserName(), calculateTaxes(), createSubMenu()

Name booleans with an appropriate, positive prefix, such as “is”, “has”, “can”, or “should”, for an easier determination between true and false.

Examples: isSoundOn, isFinished, isOpen, isLoggedIn, hasLicense, canEvaluate

Use complement names for complement entities: get/set, add/remove, create/destroy, start/stop, insert/delete, increment/decrement, old/new, begin/end, first/last, up/down, min/max, next/previous, open/close, show/hide.

Examples: getUserName, setUserName
addThumbnailImage, removeThumbnailImage
showAnimation, hideAnimation


Private variable names may be prefixed with an underscore or $ symbol as long as consistency is maintained.

Thirukkural