Week 2 - You Try It, Part 1
Python Object to model a Scratch Sprite
Design Activity
To start the week I asked you to read and watch some videos trying to develop the concept of what goes in to a Class definition. Primarily, we talked about the fact that an Object has three things:
- StateĀ (data, "instance variables")
- Actions (methods, "instance methods")
- What instances look like when they are constructed (initialization)
In this activity we want to think about the design of a couple of different classes.
You can do this on your own or with a partner if you want
When we worked with Scratch we were programming Sprites. It is very likely that each sprite you programmed was an instance of some form of "Sprite" class. Let's assume that they actually are and think about what the design for these would look like.
- What data does each individual sprite know about itself? Think about this carefully. I think you should be able to come up with no fewer than six pieces of data. When I thought about it for a while I came up with six obvious things, two mostly obvious things, and 6-12 more obscure things. Clearly your definition of "obvious", "mostly obvious" and "obscure" may differ from mine. But with a partner see how many things you can come up with.
- When you feel like you have really thought about/discussed it you can compare your answers with my answers.
- Now, we should think about the "default" values that these instance variables get when new sprites are created. For this part let's only worry about the six instance variables that I labeled as "obvious" in my solution posted in step #1.1. What are the default values given to these when a new sprite is created.
- When you feel like you have really thought about/discussed it you can compare your answers with my answers.
- Finally, what actions can each sprite perform. Again, this can get fairly large fairly quickly. So let's only focus on those actions in Scratch that manipulate the six values I labeled as "obvious".
- When you feel like you have really though about/discussed it you can compare your answers with my answers.