Albany Programming Course Supplement

Variables and Objects

The most important concept in programming is the concept of variables. 

A variable is a named storage facility for data.  You must always remain aware of all three aspects of one variable:

  1. A variable has a name which helps distinguish one variable from another1 .
  2. The variable itself is a storage facility that is reserved within the computer for a single use.
  3. The value of the variable is the actual, specific data that is currently stored in the storage facility. The value is usually changed by programmed operations when the program runs.  When the value changes, the name and the storage facility itself remain unchanged.

The term "storage facility" is often called the "storage location" to indicate that it exists somewhere in some kind of space.  It is quite accurate to think that a variable really is a small piece of one of the memory chips (called SDRAM today) that is installed in the computer.  When you buy more memory for a computer, you are making the computer more powerful by allowing it to use more variables at the same time. 

The three aspects are all different. The name is what you as the programmer write in the program to specify which variable an operation should apply to.  The storage facility is accessed by the computer when the program commands an operation on the variable specified by its name.  The value of the variable changes while the variable itself, and its name, remain unchanged.  

Today's prominence of object oriented programming ideas is due to people understanding now that variables are the best things to start with when understanding computer programs.  

  1. Variables with the same name in different method (or function) activations or in different classes (or structures) are different variables. That is why we say the name only "helps" to distinguish one variable from another. Don't worry about this when you are first starting to learn to program because you will first only work with one method at a time. Furthermore, to say every variable has a name is a simplification because some variables are distinguished and referred to by computable data values called references (or pointers). Don't worry about this until after you become thoroughly comfortable with working with variable having names you can spell. ^

There has been error in communication with booki server. Not sure right now where is the problem.

You should refresh this page.