Contents Up Previous Next Web Site Home Page

QuickCup: Basic Principles - What is a program?

A program is a list of instructions that described a task that you wish the computer perform.

In order to specify precisely your intentions, the instructions are limited to a number of core words called keywords. For example, a common keyword is IF which is used to tell the computer you wish to do something, only if something else has happened. 

This language is not understood by the computer, which uses a very fast and simplified language designed to work well with the electronic components of your computer. This is called machine code or machine language. Few people program using this directly, unless of extreme masochistic tendency.

This means that you need something that will translate the program that you have written in to machine code. This is done using a compiler. Instead, you could just translate the program straight from the source code without converting it to machine code. This would be done by an interpreter. Java uses something in-between the two of these, which will be described later.

Large programs can get very difficult to follow, and are thus split up into logical steps, each of which are called procedures. These procedures may be able to be reused in different parts of your program, thus reducing the complexity and time it takes to write your program.

Most programming languages come with a number of commonly used procedures, so that a lot of the work has been done for you. These procedures are packaged-up and put into a library.

Finally, most modern languages are in some way object-oriented. The principles of this are quite simple - imagine an object (e.g. a bicycle). It is an object. It can do various things - e.g. go, brake, accelerate and change gears. Each of these is a procedure that can be performed with the bicycle. But associated with the bicycle is various information - e.g. the make, model, current acceleration, colour, etc. These are known as attributes.

Now, let's say you wish to design a souped-up version of the sample bike - more gears, different colour, and with a bell!!! With object-orientation, rather than redoing everything again, you would borrow the design of the old bike, and just add to and replace various aspects of the object - e.g. a new attribute called bell and a new procedure called ring. Saves a lot of time. This principle is known as inheritance.

Finally, lets says we have a new object called shop. This has 50 spaces for bicycles, but until they are bought, who knows what they will be? So, we define 50 spaces that can hold a bike object (all of which share similar basic attributes and procedures) and pop different types of bikes into and out of those spaces as they are needed. In this way, we may not know in advance that the bike has a bell, but we know it can go, break, accelerate, and change gears! This principle is known as polymorphism - just to make it sound clever!

This is the basics of object-oriented programming. You build programs to reflect 'things' or objects that exist in the task or tasks you are trying to achieve.

We'll look at these concepts later and see how they can be useful in real programming.


(c) Copyright 2001-2 Arctan Computer Ventures Ltd.   All Rights Reserved.
If you have any issues regarding this on-line help, please contact the author by clicking here.
This Page was last updated: 26 April 2002 15:54