Back to main

How to Think about Programming

Three simple steps

If you ever ask "what do I do now?" while programming, then you need to follow these steps.

  1. Decide what you want the program to do.

    This is simultaneously the most important and easiest step, yet it's also the one that most people try to skip over.

    There's no "programming" involved in this step. Just describe what you want the program to do. Use any natural language -- English, Chinese, Gaelic, etc. If it helps, draw a few pictures. Use mathematical forumlas if you want. Do whatever you have to do so that you have a clear idea about the program's behavior.

    After all, if you don't know what you want the computer to do, how on earth do you expect a stupid computer to figure it out?!

  2. Write a series of steps that accomplishes the goal.

    These are still aimed at humans, not computers. Write in English and mathematics, but you cannot use any pictures at this stage. You must describe any diagrams in words or mathematics.

    Pretend that you're going to give these instructions to another human. Actually, in the labs, you don't need to pretend -- ask a lab instructor to "run" your instructions. They will follow the instructions as literally as possible, which may allow you to discover problems in these instructions before you try to program the computer.

  3. Translate the steps into a programming language.

    Only now do we actually start writing in C. If you did steps 1 and 2 correctly, it should be easy: just focus on translating each small human-instruction into code.

    If you don't know how to translate a particular instruction into code, then either look through the practice labs to learn the syntax, or go back to step 2 and add more detail to your human-instructions.

    Don't skip to this step. Seriously. You'll just waste time. Until you know what you want to do, and how to do it, don't mess around with C.

Creative Commons LicenseUnless otherwise noted, all materials on these pages are licenced under a Creative Commons Licence.