Site Overlay


Defining the steps After you know what you want your program to do, the second step is defining all the steps that tell the computer how to solve that particular problem. The exact steps that define how the program should work is called an algorithm. An algorithm simply defines one of many possible ways to solve a problem. There’s no single “best” algorithm for writing a program. The same program can be written literally in a million different ways, so the “best” way to write a program is any way that creates a useful, working, and reliable program as quickly as possible. Anything else is irrelevant. Knowing what you want the computer to do is the first step. The second step is telling the computer how to do it, which is what makes programming so difficult. The more you want the computer to do, the more instructions you need to give the computer.


Think of a computer program as a recipe. It’s easy to write a recipe for making spaghetti. Just boil water, throw in the noodles until they’re soft, drain, and serve. Now consider a recipe for making butternut squash and potato pie with tomato, mint, and sheep’s milk cheese from Crete. Not as simple as boiling water to make spaghetti, is it? The same principle holds true for computer programming. The simpler the task, the simpler the program. The harder the task, the bigger and more complicated the program:


If you just want a program that displays today’s date on the screen, you won’t need to write many instructions. ✦ If you want to write a program that simulates flying a space shuttle in orbit around the Earth, you’ll need to write a lot more instructions. The more instructions you need to write, the longer it takes and the more likely you’ll make a mistake somewhere along the way.