I had a fairly long session with the children late yesterday afternoon. We covered a number of topics.
First, I pinned up a couple of sheets I had done. One was a "dictionary", with easy definitions of class, object, property and method. The other was essentially a UML class diagram showing a single class, Creature. The class showed the properties we had talked about previously (name, age, energy, food level and health), and a single method (die).
Then we did a little exercise. I got them to go into the lounge and stand in a place. I told them that the creatures in our program are in a flat space, like the lounge, and tried to elicit from them what other properties and methods we might have to give to our creatures. They all identified that the creature had a place, a position in the world, but the methods around this were a bit of a stretch, so I told them we needed a method "moveTo" which instructs a creature to move somewhere in the space. I asked Benj to stand still, and for Emily to stand in the same position as Benj. She stood right in front of him, and I said "no, stand exactly where he is", which of course she couldn't. So we concluded that creatures cannot share exactly the same space.
So, I added Position as a property of Creature, and MoveTo as a method. I very quickly explained with the aid of a diagram what coordinates are, which are the data type of the Position property. Olivia got it - she had seen it at school. Benj and Emily were a little bemused, so we moved right along.
Seeing that they were pretty focussed (especially for the time of day), I pushed into new territory. I explained that a creature was a kind of thing that appeared in our world, and asked them if there were different things, and pointed to our lounge as an example. They enumerated various things in the lounge such as chairs, bookshelf, TV etc as being other things. I asked if these things would have the same properties and methods as a creature, and there was a mix of yes and no.
So I drew up a new diagram on the white board, this time with two classes, Thing and Creature, side by side. And I drew an arrow between them, the UML symbol of inheritance. I explained that a Creature was really a
type of thing. I said some of our properties and methods apply to all things, but only some apply to creatures, and we went through the original Creature class, and for each I asked them where it belonged on the new model. They got it pretty quickly, that Position and movement belong in Thing, but energy belongs in Creature. So that was good. We had a little discussion about 'Age', because all things have an age, but we are really only interested in the age of creatures in our system, so we left Age in Creature.
I introduced a new class on the whiteboard called Passive Thing, and said this was a class for things like furniture, which are not alive, don't move by themselves, and just "are". Does it inherit from Thing? "yes!" Does it have position? "yes!" Does it have energy and properties of a creature? "no!"
In that process, I was struck by two things:
- How children so totally absorb what you are saying if it's pitched in words and examples they understand.
- How children can quickly grasp even abstract things. Emily, only 7, understood the essential characteristics of inheritance almost immediately. She could see where things inherited in the class diagram, and where they did not. She was surprised with herself, too, that she got something seemingly as complex. I have in the past explained inheritance to non-technical adults - it takes them alot longer to grasp it.
Figuring that I gotten really good mileage on the conceptual stuff, they were rewarded with seeing the program as it now stands. I showed them how to create a creature, how to move it and feed it. I showed them how the "face" of the creature changes according to it's properties (I actually showed them the source code that calculates which image to use depending on the energy and health levels - Olivia connected it at once.)
Then I let them each have 5 minutes playing with the program (timed - everything has got to be
fair!!) It was cool to see them excited by it. The feeling of power over the creatures (you can kill creatures from a menu item - which Benj did with glee!) Creating lots of creatures (Olivia created about 20 creatures, and then realised she wasn't able to keep them all fed, so most of them died!) Emily's main focus was to create a couple of creatures, and give them meaningful and cute names, and meticulously ensure that they were completely happy and healthy, a much more emotive interaction than either Olivia or Benj.
After that, I got out another piece of paper, and asked for ideas of what can be put into the system next. These were the ideas:
- A house (Benj)
- Letting a creature sleep (Emily)
- Furniture and other objects: table and chairs, bed, washer, dryer, sewing machine (All)
- Food - I said we'd talk more about this next time. (Emily)
- The creature should grow visually with age, and have more capability as it gets older. (Olivia)
- Music (Emily) and sound generally (me)
- Friends and family (Emily)
- Pictures on the wall (Emily I think)
- Upstairs and downstairs [like our house] (Benj)
- Cellphone, and talking (communicating, more generally)
- Creatures can swim (Benj)
- Clothes (Emily)
- Toys and playing (all)
- Different spaces
- Light, day/night
- Trees (Olivia)
I added a few:
- Creatures can carry things
- Money, buying and selling
- 3 dimensional space, specifically a space that is not flat
- Group behaviour for creatures
And finally, here is the UML diagram we've ended up with: