Understanding How to Build and Write Programs



A while ago, I talked about how you can learn how to make games by modding games. Today, I’m going to show you something a little different. I’ll talk about this simple trick that I learned from a programming class. This trick helps programmers to brainstorm and problem solve a large number of tasks step by step. It’s called The Peanut Butter Jelly Sandwich Procedure! Before you think I’m crazy and decide to exit the web page, let me explain.



Make a Peanut Butter and Jelly Sandwich:

When I was in high school, I took a programming class. Little did I know, I found out it wasn’t really a programming class; Just a lazy teacher named Mr. Flake, who didn’t know anything about computer programming. He did live up to his name, but that’s beside the point. Mr. Flake actually taught something useful and I still use this trick today. The class I was in was assigned to get a sheet of paper and write the steps to make a peanut butter & jelly sandwich. The challenge of this assignment was to write every step, be very specific, and write up to at least 100 steps.


Try This Exercise:


Get out a sheet of paper and write down ALL the steps on how to make a peanut butter & jelly sandwich. When you’re done, continue reading this post.


Peanut Butter & Jelly

What steps did you write?
Did you remember to get a butter knife?
Did you bread out of the bread box?
Were you more specific?
Did you include steps like walk to the bread box?
Open the bread box? Grab the bread?
Close the bread box? etc.


If your steps looked anything like the image above, you’re a loser and you should quit programming! Never look back! No, I’m just kidding!


If you included more steps and were more specific, then you’re thinking like a programmer. If you forget your bread, you just have peanut butter and jelly. If you don’t have a butter knife you can’t spread your peanut butter or your jelly. You got to get your items from somewhere, they just don’t magically appear!


This whole assignment seemed kind of pointless to me, but I realized that if you’re more specific, and you write each and every step, it helps you to become a better programmer. When you are writing a program, you do have to be more specific. You have to tell the computer exactly what you want the program to do. This exercise helps you to think like a programmer, how to brainstorm on a number of simple tasks, and perform problem-solving on those tasks.


Now that you have an idea of how this exercise works, you can expand on this assignment if you want to. Think of it like a spider graph with lists of many steps. You can split the steps into other steps where you add honey instead, or maybe write steps on making a tuna, turkey, or ham sandwich. You can also expand on the ham sandwich and write steps on how to make a grilled ham and cheese sandwich. This is totally optional, but here’s an idea I thought up; anything you write down, if you see any repetition, combine it and write it as a function. If you don’t know what a function is, you should check out my c++ tutorials.


Now that you can think like a programmer, try playing some video games and try the same thing. Take Super Mario Bros. for example; Write each step the game takes. Include steps like displaying splash screens, displaying and handling tasks in the game menu, and the transitions to the various game modes & settings. Think of Mario; think about the steps it takes to move Mario on the screen. This could include things like:

  • if right button is down
  • switch to move right animation
  • move player right by x-speed
  • else if right button is not down
  • switch to idle right animation
  • move player by 0
  • etc.


If you’re currently working on a video game, or learning programming, play some video games. I guarantee you will learn something new, and it will help you find new ideas for your project. Make sure you write your ideas down as well. I don’t know how many times I’ve come up with great ideas and forgotten them. I regret the fact that I’ve never written most of my ideas.


I’m going to end this tutorial here. I hope this trick helps some of you who are currently working on and indie game. I know this trick may sound a little bit weird, but it actually works. Please don’t forget to comment, share, like, and subscribe.


About Justin

Computer programmer and owner of kauergames.com.
Bookmark the permalink.

One Comment

  1. Nice blog post.If you want to learn how to create windows games with python/pygame,then check out our free tutorials here:http://www.woodstockproduction.com/apps/videos/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.