From the course: Programming Foundations: Beyond the Fundamentals

Writing pseudocode - Python Tutorial

From the course: Programming Foundations: Beyond the Fundamentals

Writing pseudocode

- I want to take a trip. I want to go to Tokyo to see a Grand Sumo match, and I want to visit Seoul as well while I'm on the trip. I know the range of dates when Sumo matches take place but otherwise, my plans are somewhat flexible. I can start by researching other events that I might want to attend and when they are; things I might want to see, and getting tips from friends who've lived or visited either place on travel and accommodations. I can use all that information to make some decisions on when I want to be in which place and then I can start actually making reservations and planning the details of my trip. The initial planning step is important because I don't want end up buying a plane ticket to Seoul, for instance, when there's an event I want to be at in Tokyo. When developers write code, it's common to start with a planning phase known as pseudocoding. But don't worry, pseudocode isn't another coding language that you need to learn; just the opposite actually. Writing pseudocode involves simply writing a description of what you're trying to do using plain language. Pseudo coding helps you create a basic outline of the program you're creating. Just the process of writing pseudocode can help you map out exactly what your program will need to do. With pseudocode, you can begin to describe the structure of your program. Pseudocode also frees you from having to decide on a specific syntax to use or even a specific language. Instead, you simply describe what you need to accomplish. For developers who are familiar with multiple programming languages, the process of pseudocoding can sometimes clarify whether one particular language might be a better choice given the structure and scope of what they want to build. When your pseudocode is done, you're left with an outline for your program which you can then build out using a programming language. With the big-picture decisions made, you're ready at that point to get into the details like language and syntax. It can be tempting to skip pseudocoding and dig right into the code. The danger here is that you can get deep into coding before you realize that you haven't accounted for a certain task or behavior which might require you to start over with a new structure. It's like booking a hotel before you've really thought through how many nights you'll be in that city or even when you'll arrive. Thinking through and writing down your plans first through the process of pseudocoding helps you ensure that when you start coding, you have a sense of where you're going and you have the main factors accounted for. So be sure to include planning as the first step when you're creating a program. I promise it will help you ensure that you get where you want to go.

Contents