CSC 216/s08/be cheerful: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
m (Copy editing because I'm OCD)
Line 7: Line 7:
===Participants===
===Participants===


3 group members: 1 programmer and 2 classes
3 group members: 1 programmer and 2 classes the he writes, played by volunteers
Possibly volunteers to do the hokey pokey?


===Hokey Pokey Music/Video Candidates===
===Hokey Pokey Music/Video Candidates===
Line 17: Line 16:
===The script===
===The script===


# The coder first creates two or more people classes that are supposed to do the Hokey Pokey.  He tells them individually how to do the hokey pokey.   
# The coder first creates two or more people classes that are supposed to do the Hokey Pokey, by telling them individually how to do the hokey pokey.   
# Because he has a bad memory, he forgets to tell one to turn himself about and to do the incorrect 2nd action.
## Because he has a bad memory, he forgets to tell one to "turn himself about" and to do the incorrect 2nd action.
# They dance the first 2 segments (right foot, left foot) and get it wrong.
# The "classes" dance the first 2 segments (right foot, left foot) and get it wrong.
# The coder decides to use superclassing and inheritance so that all of his people share the same instructions -> show the video.
# The coder decides to use superclassing and inheritance so that all of his people share the same instructions, so he shows the video.
# They dance the next 2 segments (right arm, left arm) right!
# They dance the next 2 segments (right arm, left arm) right!
# The best part is that now that I have a superclass, I can extend HokeyPokey to as many classes as I want! Like... the whole class! ;)
# The best part is that now that the coder has a superclass, I can extend HokeyPokey to as many classes as I want! Like... the whole class! ;)
# Those willing can watch the video and do the hokey pokey with us. :D
# Those willing can watch the video and do the hokey pokey with us. :D
# Reiterate how this example applies to real programming.
# Reiterate how this example applies to real programming.

Revision as of 17:54, 25 March 2008

That's what it's all about!

The problem

Teach the value of superclassing and writing DRY code to prevent error.

Participants

3 group members: 1 programmer and 2 classes the he writes, played by volunteers

Hokey Pokey Music/Video Candidates

The script

  1. The coder first creates two or more people classes that are supposed to do the Hokey Pokey, by telling them individually how to do the hokey pokey.
    1. Because he has a bad memory, he forgets to tell one to "turn himself about" and to do the incorrect 2nd action.
  2. The "classes" dance the first 2 segments (right foot, left foot) and get it wrong.
  3. The coder decides to use superclassing and inheritance so that all of his people share the same instructions, so he shows the video.
  4. They dance the next 2 segments (right arm, left arm) right!
  5. The best part is that now that the coder has a superclass, I can extend HokeyPokey to as many classes as I want! Like... the whole class! ;)
  6. Those willing can watch the video and do the hokey pokey with us. :D
  7. Reiterate how this example applies to real programming.

References