Computer Science 30
4.0-Programming & Design
 

Creating Variables and Objects

When your program calls for the creation of a variable or the naming of an object in the properties window, be sure to follow the listed conventions:

  1. A name should generally indicate its purpose.
    i.e. calcBtn(calculate button), exitBtn(exit button), temp(temperature), ctr(counter)
    -use only letters, numbers and the underscore character "_" (small letter first).
    -no spaces allowed in variable/object names.
    -in compound words each new word after the first begins with a capital letter.
  2. Some programmers also indicate the type of variable being created.
    i.e. doublAverage, intMyAge
  3. Variables should be assigned an initial value.

Remember! Just because the machine can read it, doesn't mean it's good code. Choose your names wisely and you will save yourself much time and frustration in finding bugs and/or fine tuning the program. Be as clear as possible.

Back

©Copyright Saskatoon Public Schools 2005 --- Page updated Friday, 2006-05-12 9:53 AM