Basic Review of Programming
Before introducing the concepts of Object Oriented Programming to Game Designers students, I decided to do a basic revision of the programming concepts. I wrote this post to let all the underlying ideas and concepts be in one place to help the students find the information.
If you’re reading this post and have Computer Science background, bear in mind that this is intended to be a revision of programming for Game Designer Students, people that need to understand the basic of programming but don’t need to be ace programmers. Whatever your background is, if you want to improve your understanding of programming and haven’t read Structure and Interpretation of Computer Programs, go read it as soon as you can. There’s a free version online here.
If you have any suggestion to improve this revision, send me an email and I will be glad to add the good ones to this post.
One last thing before the review. I use Processing because it’s very simple to have something running and the results are visual instead of the old printing and typing on the OS Shell, something Seymour Papert and others have argued since the 1960 is the best way to introduce programming concepts to the novice programmers. The code discussed in class can be found at my OpenProcessing Profile.
One way of thinking about a Program is to describe it as a set of Variables and Instructions. Variables are places of the computer memory that you assign a lable and are used to store information. Instructions are the actions the computer does in order to execute the program. The most basic thins one needs to know about each one are:
Variabless:
- Declaration: give its name, and in a static typed language, like the one used in Processing or in C#, tell the compiler/interpreter which type should be associated with this variable. Basically you set the size of the memory to be associated with this variable.
- Assignment: give the variable its value.
- Variable Simple: one that can store just one value in this variable.
- Compound: a variable that can store more than one value. In this case you need more than just the name of the variable, one or more indexes, to find the value you want. The most basic of this type of variable is an Array.
Instructions:
- Sequential: the default instruction for most computers. It doesn’t have to test anything in order to know where to go after completing this instruction: it goes to the next one stored in the program.
- Decision: one that tests a condition and can have one or multiple branches of code to choose from based on the condition.
- Repetion: a block of code is executed repeatedly until a condition is reached which causes the program to do another thing.
- Cluster of Instructions: a function, a block of code associated with a name. This block can return a value and in many cases need a set of external parameters to work properly.
For each one of these concepts, I wrote a simple Processing Sketch to show how to do this in code. They are all available in my OpenProcessing Profile.
End of Line