Pseudocode is the plain English equivalent of computer programming. In the planning stage of a script or program, before the actual code is written, programmers will mock up the necessary code in pseudocode. The purpose of mocking up code in pseudocode, according to Dr. John Dalbey of California Polytechnic State University, is that "it allows the designer to focus on the logic" yet not get "distracted by details of language syntax." Even relatively short scripts used for Web programming benefit from good planning and some well-written pseudocode.
- Skill level:
- Moderately Challenging
Other People Are Reading
Write a rough flowchart of your script's tasks. For example, you would like to build a quiz for your website that allows visitors to test their knowledge of movies. Think of how your script needs to function to carry out its task. In the case of a quiz, it must ask questions that are then graded and tallied. Since the quiz exists on a website, it will use a Web form written in HTML. So your script does not need to ask the questions. That leaves your script with grading and tallying.
Add to your flowchart an action that triggers the script. In an online quiz, since the script will only grade and tally answers to questions, clicking the "Submit" button should trigger the script. Write this trigger above your rough flowchart.
Add to your flowchart any information each step needs to perform its task, starting at the logical beginning. For example, the first step the quiz performs is grading. To grade, the program needs to get the answers from the Web form. Write this information down on your rough flowchart, next to the step.
Note on the flowchart what your program needs to do with the information at each step. At the quiz's grading step, it needs to read each question's answer and then compare it with the correct answer. If an answer is correct, it is given a point. No points are given for incorrect answers. At the tallying step, the script simply adds up the points associated with each answer.
Add some notes on your flowchart marking where the script needs control structures. Control structures include loops and conditional statements. In your quiz, you should see that the grading step needs to repeat itself for every question on the quiz, so note that the step requires a for-loop. The script will likely need conditional statements as well.
Write your pseudocode based on the rough flowchart you created. Start at the top and write your action, such as "User submits quiz." Start the next line at an indent and write the first step. Use indents and white space to make the code readable, and set your variables, just as you would in a real script. Also write a line of pseudocode to show any output the script must generate.
Check your pseudocode by reading it aloud to yourself and following the steps in your head, pretending to be the computer. If any information, processing, input or output is missing, add these where they are needed.
Tips and warnings
- Draw your finished product, as you imagine it, on a piece of paper to help you visualise exactly how the script will work.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for