CS 139 Algorithm Development
Lab01B: Programming with Objects
Background
In today's lab you will explore the concepts of objects, instructions, and sequence.
We will focus on examples from the arts including music, design, drawing, and dance.
Objectives
The students will:
- learn to express a complex activity using a sequence of simple instructions
- become familiar with object-oriented programming concepts
- be able to create a Scratch project that combines animation and music
- understand and practice incremental development techniques
Key Terms
Object : programming construct that combines code with data (e.g., a sprite or stage)
Materials Needed
- Enrollment in the class (for Blackboard)
- "Dance Party" handout (available in PDF)
- Optional: headphones for computer audio
- Optional: worksheet for writing answers
Instructions
Write the answers to the numbered questions in a separate file.
You may be asked to share your answers with the rest of the class.
Submit your Scratch project and your answer file electronically via Canvas at the end of the lab period.
References
This lab is adapted from the Scratch Curriculum Guide v20110923, released under the Creative Commons Attribution-ShareAlike license.
Part 1: Giving Instructions
Step 1.
List five situations during the past week when you used instructions written by someone else.
Step 2.
What are instructions good for, in general?
Why do we write instructions? What purposes do they serve?
Step 3.
Group activity. We need four people who don't mind being bossy, and four people who don't mind being bossed.
Please raise your hand if you would like to participate. After we complete this activity, answer the following questions:
- What was easy/difficult about being the bossy person?
- What was easy/difficult about being the bossed person?
- How does this activity relate to what we're doing with Scratch?
Part 2: Dance Party
Tip: Don't forget about the Scratch resource library at http://info.scratch.mit.edu/Support
and example projects at http://scratch.mit.edu/channel/featured.
Step 4.
Today we are going to make a dance party, which is a Scratch project
"where sprites get down with cool costumes and funky beats."
Start by adding a sprite with multiple costumes that responds by dancing
when clicked.
- What is the difference between a sprite and a sprite's costume?
- When might you want to add a new sprite instead of a costume?
Step 5.
An important programming technique is "incremental development" or adding and testing small amounts of code at a time.
At the end of this step, your sprite should have a complex sequence of instructions.
Refer to the "Dance Party" handout for ideas.
- While creating your sprite in step 4, how many blocks did you add before testing them out?
- In practice, how often should you stop "programming" and see how it works?
Step 6.
Repeat step 4 until you have several different sprites, each with their own unique dance moves.
- How can you test small portions of your code after it gets relatively long or complex?
We will pause the lab at 30 minutes and 60 minutes for a gallery walk of the projects-in-progress.
We encourage you to look at each others' code and ask questions about unfamiliar constructs.
Step 7.
Think back to your reading of the textbook (Chapter 1.6 and 1.7).
- Which aspects of the programming process apply to Scratch? Which ones don't?
- How does your Scratch project relate to object-oriented programming?