HTML and CSS   XSLT   JavaScript   Images   Soft   Etc  
Vladimir Tokmakov

Prefixes and underscores 29 June 2005


What are prefixes good for?

  1. Prefixes let you know data type or object class.
    Of course, they cannot stop you from assigning a string value to an integer variable, but they sure can help you to avoid such a mistake.
    If you use prefixes thoroughly when writing a script, you’ll be able to easily tell whether it is correct to write sValue++.
  2. Prefixes are useful for determining paths to associated methods and templates.
  3. Previxes can prevent unwanted redefining.
    This is particularly important if there are many scripts—it’s often the case when several methods named the same, but refusing to work the same. This just as well applies to names of classes in stylesheets.

Why underscore? But why not?

Since spaces are not allowed in the names, here are the options to choose from:
  1. optionNumberOne
  2. OptionNumberTwo
  3. option-number-three
  4. option_number_four
Lets look at them from a practical point of view:
  1. As a rule, this pattern is accepted in basic languages, which may lead to an unwanted redefinition or even an error.
  2. In JavaScript, for instance, you cannot create a function with a hyphen in its name.

And from an aesthetic point of view:

What is the purpose of such naming anyway? I guess, the answer would be convenience and readability. And word combinations are readable when there are some kind of dividers between words. Orelseitisnotatalleasytoread.

  1. have You Ever Seen Messages Communicated Like This? Maybe on some ads, yet most unlikely.
  2. And acronyms are often spelled in capitals. But what if you need to write two of them in a row?
  3. Hyphens can be used for other purposes.
  4. In my opinion, the best substitue for space is ;p

Order a design...