Pseudocode Tutorial: The BasicsFew people create programs overnight. Instead, most programs evolve over time. Just as architects often build cardboard or plastic models of skyscrapers before a construction crew starts welding I-beams together, programmers create mock-ups prototypes of their programs first. A prototype usually shows the user interface of the program, such as windows, pull-down menus, and dialog boxes. The whole idea of the prototype is to show what the program looks like and how it acts, without taking the time to write commands to make the program actually work. After the programmer is happy with the way the prototype looks, he or she can proceed, using the prototype as a guideline toward completing the final program. After you use Visual Basic to create a prototype that shows how your user interface works, you can start adding actual commands to later turn your prototype into an honest-to-goodness working program. After you refine your prototype until it shows you exactly how your program will look and act, the next step is choosing a programming language to use. You can write any program by using any programming language. The trick is that some languages make writing certain types of programs easier than others. The choice of a programming language to use can pit people against one another in much the same way that religion and politics do. Ultimately, no one cares what language you use as long as your program works. These mock-up instructions are known as pseudocode. If you need to write a program that guides a nuclear missile to another city to wipe out all signs of life within a mile radius, your pseudocode may look as follows:. In the preceding example, you can see that each pseudocode instruction needs further refining before you can start writing your program. You can refine the instructions even further to specify how the computer works in more detail, as follows:. Make sure that the target coordinates are valid: 1 Make sure that the target coordinates are complete. In other words, they start at the top with the general tasks that the program needs to do and then work their way down, defining each task in greater detail until the pseudocode describes every possible step that the computer must go through. Writing pseudocode can prove to be time-consuming. But the alternative is to start writing a program with no planning whatsoever, which is like hopping in your car and driving north and then wondering why you never seem to wind up in Florida. Pseudocode is a tool that you can use to outline the structure of your program so that you can see all the possible data that the computer needs to accomplish a given task. The Technical Details of Writing a Program. About the Book Author Wallace Wang is a bestselling author with more than 2. He's also a stand-up comic who has performed on TV.
Writing computer code for a new program is a complex process. Pseudocode is perhaps the best way to ensure all the necessary information is there. It consists of writing out the computer code in simple, easy-to-understand English before creating it in a specific programming language. Instead of jumping straight into a programming language, computer programmers use pseudocode to clearly and concisely list out what they hope to accomplish with their new program. Not only is pseudocode a great way to show others what the coding behind a program will look like, but it also helps ensure all the important pieces to the puzzle are there. The natural language of pseudocode makes it easy for programmers to see that all of the essential details are included. Beyond this, pseudocode acts as a template or outline for the process of actual writing the computer code in the programming language of choice. One important benefit of writing pseudocode before programming is catching potential mistakes from the get-go. Pseudocode combines normal written language with the programming language for an easy-to-understand outline. For starters, pseudocode simply makes the task of creating a new computer program more simple and straightforward. Writing out the code in English enables you to create a verbal outline to follow during the programming stages of the project. Pseudocode gives you the tools needed to ensure that everything you need will be included during programming. It lets you catch mistakes before they become mistakes. It breaks the program down in a simple manner so that all programmers are on the same page. There is no standard way to write pseudocode. The goal is simply to properly outline everything in your mind. Follow these rules to ensure that everyone else on the team is on the same page. Perhaps the most important rule is to place clarity first. Make your pseudocode as clear and concise as possible, so there is no question as to what you mean. Two of the most important things you must understand when it comes to writing pseudocode are algorithms and basic algorithm constructs. As mentioned above, there is no standard procedure for writing pseudocode. Make sure that your pseudocode includes all of the essential information with our pseudocode cheat sheet. Remember these tips and best practices while writing pseudocode to catch mistakes before programming and to ensure that everyone on the team understands the program. What Is Creativity? How to Write Pseudocode. What is Pseudocode? Pseudocode is a method of writing out computer code in the English language. Pseudocode is Subjective The trickiest thing about pseudocode is that it is subjective. Algorithms and Basic Constructs Two of the most important things you must understand when it comes to writing pseudocode are algorithms and basic algorithm constructs. Understand Algorithms — An algorithm is the steps you must take to achieve a specific goal. Combine the Pieces — Take the information you want to relay and use algorithm flow to create a straightforward outline. Standard Procedure As mentioned above, there is no standard procedure for writing pseudocode. One Statement Per Line — Express each statement or action on its own line. Focus on Meaning — Write what the program will do. Standard Programming Structures — Follow the algorithm flow discussed above to create easy-to-follow structures. Utilize Blocks — Group similar actions together into blocks to separate the pseudocode into separate steps. Keep It Simple — Simplicity and clarity are key. Write down what the actions will be, not how to program them.
How to Write Pseudocode