How to structure the first program

When you learn how to program, a big question is: how do you structure the program in the best way? There are a lot of approaches for this, but to get started, this one works pretty well: Input-Process-Output.

Input – Process – Output Model

With this approach, the program has three phases: Input, Process and Output.

In the input phase, the program accepts user input. This can either happen through command line arguments or direct user input.

During Process, the user input is used to calculate a result. Now, this can involve math, but it doesn’t have to. For instance, your program could read / write a file.

The last phase outputs the results that got calculated in the previous step. After this is complete, the program ends.

I’m curently using this approach to teach the foundational building blocks of programming to my students during the Intro to Web Development class. It allows us to focus on learning the foundations without having to put too much effort into also understanding event loops or how HTML and JavaScript can interact with each other.

Have you used this before? Share your story below in the comments!

Leave a Reply