Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
  1. Code
  2. Open Mike

Open Mike: Wording


Do you updateDatabaseFields() or udDBFields()? This is Open Mike, a series of discussion posts to throw the cat amongst the pigeons. These posts are all about you — we want to hear your opinions, ideas, and thoughts. We've spoken about prefixes before; now let's talk about the actual words you use to name your AS3 objects.

Do You Abbreviate?

Do you spell out the full words of your variables' and functions' names or do you use some sort of shorthand?

checkAllOptionsHaveBeenEntered() vs. chkOptsEntd()

Perhaps you use a mixture: shorthand for common coding words (like num instead of number) and longhand for others.

numberOfTrophies vs. numTrophies

How do You Name Booleans?

Booleans: since these are always either true or false, I like to word them in a way that can always be answered 'yes' or 'no'.

Examples: hero.hasTheSword, basketballPlayer.isQuiteTall

UrbanSquall's coding conventions go further and insist that Boolean names always begin with is, has, or can.

What about you?

What do You Call Your Functions?

Functions and methods generally involve doing something, so it usually makes sense to give them names which are verbs (or verb-subject pairings).

Examples: refresh(), undo(), restartGame(), checkFormDataIsComplete()

Do you follow this as a convention, or are there any cases where you might not use a verb in your function name?

When a function requires arguments, do you try to make it clear from the name what arguments you're expecting?

For example: pingPongBall.move(x, y) vs. pingPongBall.moveTo(x, y)

Sometimes a function requires totally different kinds of arguments, which can lead to confusion. For example, suppose we have a gun object that fires a given bullet at a given target. There are a few options for what we could call this method, including:

Which is better?

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.