Procedures in Alice3: Top Down Code and Reusable Code

The goal of this lesson is to learn to create procedures.
These methods allow you to break your program into subparts,
thus making it easier to create large programs.

In this module, you will create procedures. Procedures let you write code for an object to perform an action.
For instance, you can write a procedure for a biped to wave. Then, whenever you want a character to wave, you just call the procedure.
The code can then be used many times and for many objects.
This will allow you to decompose a program into functional subprograms and create and test larger programs.
We will also use parameters so that we can tell the procedure how fast to wave, or how many times to wave. We can also use parameters to tell who the bunny faces when they wave.
This a very powerful tool and will let you greatly improve the efficiency of your code.
In order to do this you will:

  • Write code to animate a character, then convert that code to a procedure so that it can be used many times and for other characters.
  • Utilize parameters for flexibility.
  • Decompose a program into subprograms: myFirstMethod will be mostly calls to procedures and functions from now on.

Print the lesson

Please study the material at each of the links below.

  1. Procedures for top down design: Video shows how to use procedure for top down design.
  2. Loki Waves: Video shows statements for making Loki wave.
  3. A Biped Waving Procedure: Copy the code for Loki waving to create procedure for any biped to wave.
  4. Adding Parameters to a Procedure: Parameters are added so that we can vary the amount to wave and times to wave.
  5. Anyone can walk: Video on making the code for Freya walking into a procedure for any biped to walk.
  6. Self Study Questions
  7. Discussion Questions

Active Learning

Use procedures to create an exercise class.

Like us on Facebook:


OER: Open Educational Resource
Creative Commons License Author: Janet E. Joy; Publisher: Zebra0.com
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Creative Commons Attribution-NonCommercial 4.0 International License
Last modified: May 17 2017 16:45:38.