Friday 18 October 2013

How to Write Pseudocode

You may be asked to write pseudocode for 1 or more projects if you are involved in any kind of computer programming or engineering. Pseudocode is a specific kind of documentation that falls between human language and computer programming. In pseudocode, the written code is not meant to be read by the machine, but by the human. Pseudocode mimics many elements of actual computer code, but with more of a focus on readability and less on technical requirements. This is because, where computers need a very strict syntax to operate, humans are more able to interpret similar versions of the same code or language elements.

EditSteps

  1. 1
    Write initial steps of pseudocode that set the stage for functions. The first parts of a code typically define the variables and other elements that will be used to create functionality.
    • Include dimension variables. Write code that shows how each variable or data element will be used.
    • Set up controls. You'll need to define your controls in pseudocode--from text and images boxes in OOP languages to basic controls in simpler codes--much as you would in a regular project.
  2. 2
    Add functional pseudocode. Use pseudocode principles to add specific "event-driven" code when you have completed the "setting" for your project.
  3. 3
    Look over your pseudocode for compliance with coding conventions.
    • Although you may not use the exact syntax of a programming language such as C++, Visual Basic, Java, PHP or other common computer languages, you will want to include some of the most common elements of code.
    • Words like if, then, while, else and loop will be the same as they would in many different computer languages.
  4. 4
    Add comments or other identifying markers.
    • In actual computer code, comments serve the role of identifying tasks and parts of the code to the reader. In pseudocode, where the actual code text is made more readable, comments may, or may not, be necessary. Assess your particular project to understand whether you need to insert comments in it to make sure that you and your readers are on the same page.
  5. 5
    Read over the finished project for logic and syntax. Again, syntax does not have to be exact, but your pseudocode should still make sense.
    • Assess your code modules according to the various elements that are involved in them. For example, core operations for the computer include reading or getting information from a file, writing to a file or display on the screen, doing mathematical calculations, valuing data variables and comparing one or more elements. Each of these has its own place in a computer code project and in the pseudocode that you will write.
    • Work specific tasks into the pseudocode. When you have identified each task, represent it with readable pseudocode that, while mimicking the actual code language that you may use, may not exactly follow the computer programming language.
    • Make sure all of the applicable elements are in the pseudocode. Even though you may not need some of the more technical items, like variable declarations, you will still need to have every task and element represented clearly in the text.