This chapter has covered an awful lot of ground, but it's really important stuff. The techniques we've looked at are the building blocks of programming. Every program is made up from procedures, and these all use variables , other procedures, built-in functions, and so on. Having a good understanding of this will make it easier to understand other code that you see, as well as making your own code better.
In this chapter, we looked at:
What procedures and functions are. They are small sections of code that perform a task. Sometimes that task may be small, and other times it may be quite large, but the chunk of code is usually a logical unit, with a defined purpose. Making ice cream and making frozen yogurt are two separate tasks , although their procedures might be similar.
Naming conventions, to show the importance of consistency. As you see more and more code, this can ease your understanding, as well as making it quicker to maintain.
What variables are, and how they can be used. Variables are where we store temporary information during a procedure. They allow us to store and manipulate different types of data.
The scope (where the variable can be seen from) and lifetime (how long the variable keeps its value) of variables. It's important to always think about how great a scope you want for each variable, and how their lifetime will affect the code you're writing.
Now that you've got a good understanding of these techniques, let's move on to look at how we can make decisions in our code, and use looping to help us with repetitive tasks.