Initialization
Initialization is something you do at the beginning of a program to ensure you start in a known state.
Every Day Life ExampleInitialization happens at the beginning of every game. Everyone starts with a zero score. If you don’t initialize, then people would start with the last score they had and that wouldn't be fair.
|
Classroom ExampleLet’s say you do the same thing as in the "sequence" example – stand up, clap 5 times, say “meow” and stamp your foot 2 times. Are you standing or sitting at the end of this? What happens if I ask you to do it again? You’re already standing, so you can’t stand up again. In order to make this work, you should initialize the script by making sure everyone is sitting down at the beginning. That way your script will work the way you expect it.
|
Scratch Example
In this example, we start with the script we wrote for Programming Concepts: Sequence. Click here to learn more about how the Scratch Stage works.
|
Click on the image below to access this Scratch program. You can click "see inside" to see the code.
|