Visual Exception Handling Excercise: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==The Throw Down==
==The Throw Down==


Give the title of your exercise, which may include the name of the topic you are covering, or some other catchy title.
 


===The problem===
===The problem===


Describe what you are attempting to teach students by this exercise.
Students learn about how thrown exceptions are caught and handled. Exceptions are represented in a real-life set diagram constructed of trays and buckets. Students are given "exceptions" to "handle" by tossing them into the appropriate buckets.


===Participants and Props===
===Participants and Props===


One class member will participate in the activity at a time. There will be one large tray, labeled Exception. There will be two medium-sized buckets labeled ClassCastException and IO Exception, and one small bucket labeled FileNotFound. Cards with different lines of code for each student will be written prior to class.  A tennis ball will also be used.
One class member will participate in the activity at a time. The activity can be performed with a variety of sizes of trays and buckets with large labels. One suggested combination is one large tray, two large buckets, and one small bucket. In this scenario, both large buckets (labeled 'IOException' and 'ClassCastException') sit inside the tray ('Exception'), and one small bucket ('FileNotFoundException') sits inside one of the large buckets ('IOException'). This symbolizes the relationship that IOException and ClassCastException extend Exception, while FileNotFoundException extends IOException. The activity will also require a tennis ball and several cards with code written on them.


===Instructions===
===Instructions===


Students will come up one at a time and be given a card with code written on it.  Equal numbers of cards will be provided for students. They will also be given the tennis ball.  The student will then decide which exception handling method should be used to fix the code and attempt to throw the tennis ball into the appropriate bucket/bin.  If they make the bucket and it is the right exception, they will be awarded one point.  The student with the most points at the end of the game wins.
Students will come up one at a time and each be given a card. The card will contain code which will somehow fail, throwing an exception. The student will then receive the tennis ball.  The student will decide which exception the code throws and attempt to 'throw' the tennis ball into the appropriate bucket/bin.  If they make the bucket and it is the right exception, they will be awarded one point.  The student with the most points at the end of the game wins.


===Acknowledgments===
===Acknowledgments===


This exercise was created by ... and John Phillips
This exercise was created by Jason Cockrell and John Phillips

Revision as of 01:02, 18 November 2009

The Throw Down

The problem

Students learn about how thrown exceptions are caught and handled. Exceptions are represented in a real-life set diagram constructed of trays and buckets. Students are given "exceptions" to "handle" by tossing them into the appropriate buckets.

Participants and Props

One class member will participate in the activity at a time. The activity can be performed with a variety of sizes of trays and buckets with large labels. One suggested combination is one large tray, two large buckets, and one small bucket. In this scenario, both large buckets (labeled 'IOException' and 'ClassCastException') sit inside the tray ('Exception'), and one small bucket ('FileNotFoundException') sits inside one of the large buckets ('IOException'). This symbolizes the relationship that IOException and ClassCastException extend Exception, while FileNotFoundException extends IOException. The activity will also require a tennis ball and several cards with code written on them.

Instructions

Students will come up one at a time and each be given a card. The card will contain code which will somehow fail, throwing an exception. The student will then receive the tennis ball. The student will decide which exception the code throws and attempt to 'throw' the tennis ball into the appropriate bucket/bin. If they make the bucket and it is the right exception, they will be awarded one point. The student with the most points at the end of the game wins.

Acknowledgments

This exercise was created by Jason Cockrell and John Phillips