GoldBorder Title GoldBorder Title
Programming: Lesson 1, Building Blocks
"A variable is a way for a computer to keep track of something the programmer (YOU) wants."

Variables are empty blocks of memory that have two parts, a Label and a Size/Type.

  • Label
      A Label is a way to find the blocks.
  • Size/Type
      A Size/Type is a way to make a big enough empty block to hold what is needed.

Non-Techie Scenario
    GB wants the computer to create three blocks of memory to store stuff. His needs are:
    • 100 Cookies
    • 10 Ice Cubes
    • 2 French Fries
    The size of the blocks for each are different, since the amounts are different. The sizes are:
    • 100 Cookies: Large Block
    • 10 Ice Cubes: Medium Block
    • 2 French Fries: Small Block
    He also needs different types of blocks, depending on what is going in them. These are:
    • 100 Cookies: Cool
    • 10 Ice Cubes: Cold
    • 2 French Fries: Hot
Going by GB's needs, he asks the computer the following:
  • "Please create a large, cool block and give it a label of 'Cookies'"
  • "Please create a medium, cold block and give it a label of 'Ice'"
  • "Please create a small, hot block and give it a label of 'Fries'"
As you can see, depending on what GB wants the computer to hold for him, he needs to ask for a block that will work. A small/cold box works great for two (2) ice cubes, but, a large/hot box is too large and would melt the ice.

GB could make his programming life easier by making very large boxes all the time. But, the smaller box, the quicker the computer can process it. As a programmer you should always be writing code that uses as little of the computers effort as possible.