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:, target);
gun.fireAt(target, bullet);
gun.fireAtTarget(target, bullet);
gun.fireBulletAtTarget(bullet, target);

Which is better?

Related Posts
  • Web Design
    HTML & CSS
    An Introduction to Error Handling in SassSass error
    I don't know about you, but I really don't like letting the Sass compiler fail. In this tutorial we'll introduce the concept of handling Sass errors properly.Read More…
  • Business
    How to Write an Online Market Research SurveyResearch survey
    Market research is the key to a successful business. If your business isn’t meeting a need, you’ll struggle to get customers through your doors. Market research is your way of discovering what your customers need. Once you know that, you’ve got the foundation of a successful business.Read More…
  • Code
    JavaScript & AJAX
    JavaScript ObjectsCover
    In JavaScript, objects are king: Almost everything is an object or acts like an object. Understand objects and you will understand JavaScript. So let's examine the creation of objects in JavaScript.Read More…
  • Code
    iOS SDK
    Objective-C Succinctly: Methods0e5ds8 preview image@2x
    In this chapter, we'll explore Objective-C methods in much more detail than we have in previous chapters. This includes an in-depth discussion of instance methods, class methods, important built-in methods, inheritance, naming conventions, and common design patterns.Read More…
  • Code
    Cheat Sheets
    The WordPress Coding Standards: Bringing It All TogetherThe wordpress coding standards
    When it comes to writing a series of blog posts, one of the most challenging aspects as a reader is actually keeping up with every post that is published. Even if you do manage to try and keep up, posts that are in excess of 1,000 words - especially those that include code - can take time that many of us don't have especially when it comes to juggling our work lives, home lives, hobbies, and other things. So in order to make sure that the information presented throughout this series is still presented in a digestible way, I thought I'd experiment with doing a summary of the entire series. That way, for those of you who have missed an article or haven't had the time to sit down and go through each article, can still get the gist of each point mentioned throughout the articles. With that said, let's take a look at everything we covered when reviewing the WordPress Coding Standards.Read More…
  • Code
    Cheat Sheets
    The WordPress Coding Standards: Naming Conventions and Function ArgumentsThe wordpress coding standards
    In this series, we're taking a deep dive into the WordPress Coding Standards - specifically, the PHP coding standards - in order to evangelize and understand how quality WordPress code should be written. Despite the fact that this is documented within the WordPress Developer Handbook, I think there's something to be said for understanding the rationale behind why some things are the way that they are. Remember: Our ultimate goal is to make sure that we're writing code that conforms to the coding standards so that we, along with other developers, are able to more easily read, understand, and maintain code for themes, plugins, and applications built on top of WordPress. In this post, we're going to be taking a look at how to handle naming conventions and function arguments.Read More…