Last Update: March 20, 2002 www.doomstone.co.uk
Welcome to DoomStone:
This is a personal page, designed by Kieran McAtamney-Sanders,
Articles: Programming Principles

Contact Me
Personal Info
Curriculum Vitae
College Work
Articles
Emperor Mods
Music
Films
Books
Links
Home

News: 15.03.02

Just added a bunch more stuff to the 3rd Year projects section. More on the way as I finalise the details...

Most people think that computers are good at performing complex tasks. They aren't. What computers are good at is performing lots of simple tasks very quickly - a vital skill to acquire in learning how to write effective programs (and this applies equally to director scripts or free-running programs in C++) is being able to break down a comlex task into a series of simple tasks

For example, let's take an everyday task - making a cup of tea, now imagine you have to instruct (program) someone else to do it. This person knows nothing about the task, so simply saying "make a cup of tea" is no good. you need to break it down into its component tasks, so you might say:

  • Fill the kettle
  • Switch the kettle on
  • Wait until the kettle is boiled
  • Place a tea bag in the cup
  • Fill the cup with the water
  • Wait until the tea is brewed
  • Remove the tea bag
  • Add milk to the cup
  • Stir the tea

Believe it or not, the list above is a simple program. Of course, when you come to program a computer, it starts out with no knowledge of the task at hand, so following our "Tea" example, you would first have to explain what a kettle is, how to work the tap, how to tell when the kettle is full and so on...

So, what does all this Tea making business have to do with programming then?

OK, so you're not likely to want to write a script for making tea, but the principle outlined above remains the same regardless of what task you're trying to achieve, and which system, application or programming language you are using, before you write a single line of code it is important to break the task down into the smallest sections possible. This can be done either as a list of instructions in plain english (as above, often called Pseudo-Code by programmers) or as a flow diagram, whichever you feel will most clearly illustrate your task.

It is entirely possible to outline your entire program in this form, without once touching a computer, leaving you only the much less daunting task of translating your Pseudo-code into Lingo, C++, Pascal or whatever.

So, next time you need to write a script to perform a task, take a moment to break it down into its component tasks - in the long run, you'll save yourself hours of struggling with faulty scripts later in the project, and will probably find a much simpler solution than if you just dive in and start scripting.