Csc.216/s08/nurture strength: Difference between revisions
No edit summary |
No edit summary |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Arguably one of the most powerful features of any object-oriented language is that of inheritance. This feature allows the programmer to define a basic object type (the base class), and then extend that object and its functionality in further classes (derived class). The derived classes contain the same variables and functions of the original class, but allow the programmer to extend the original functionality to whatever degree is necessary, without actually changing the functionality of the original base class. Unfortunately, it is often the case that beginning programmers have a difficult time fully grasping the concept of inheritance, despite its applicability and usefulness. This exercise will present a fun and engaging method for representing a more concrete example of the inheritance process, and will hopefully lead to a more comprehensive understanding of the inheritance process. | '''ACTIVE LEARNING EXERCISE 2: INHERITANCE''' | ||
Arguably one of the most powerful features of any object-oriented language is that of '''inheritance'''. This feature allows the programmer to define a basic object type (the '''base class'''), and then extend that object and its functionality in further classes ('''derived class'''). The '''derived classes''' contain the same variables and functions of the original class, but allow the programmer to extend the original functionality to whatever degree is necessary, without actually changing the functionality of the original '''base class'''. Unfortunately, it is often the case that beginning programmers have a difficult time fully grasping the concept of '''inheritance''', despite its applicability and usefulness. This exercise will present a fun and engaging method for representing a more concrete example of the inheritance process, and will hopefully lead to a more comprehensive understanding of the '''inheritance''' process. | |||
* NOTE: The base object used in this example will be a car; however, you can make your base class anything that you want, as long as it is within the scope of the exercise. | * NOTE: The base object used in this example will be a car; however, you can make your base class anything that you want, as long as it is within the scope of the exercise. | ||
(1) Obtain a piece of cardboard (or poster board) of reasonable size, and cut it into the shape of a basic car chassis. | (1) Obtain a piece of '''cardboard''' (or poster board) of reasonable size, and cut it into the shape of a basic car chassis. | ||
(2) Using markers or crayons, add some basic details to the car shape, and for each detail, write a description on the related of | (2) Using markers or crayons, add some basic details to the car shape, and for each detail, write a '''description''' on | ||
the related part of the car. For example, if we assume that our car has an engine, we will draw an outline of an engine, on | |||
the shape we just drew, we will write "engine." This is for concreteness' sake, so that participants in the activity will | |||
have a visual indicator of each of the features of the '''Simple Car'''. | |||
(3) Add a few more details and descriptions in order to give a basic layout for our Simple Car. This car will represent our base | (3) Add a few more details and descriptions in order to give a basic layout for our '''Simple Car'''. This car will represent our '''base''' | ||
'''class''', with each of the labeled features representing individual '''variables''' and/or '''methods'''. | |||
($) Attach the basic car model to the wall or a white board using tape, so that the class can see it clearly. | ($) Attach the basic car model to the wall or a white board using '''tape''', so that the class can see it clearly. | ||
(5) Have each student (or group of students, depending on class size) come up with some sort of accessory or improvement which | (5) Have each '''student''' (or '''group''' of students, depending on class size) come up with some sort of '''accessory''' or improvement which | ||
they would like to add to the basic car. Have them draw and label these accessories on paper, similar to the method used to | they would like to add to the basic car. Have them draw and label these accessories on paper, similar to the method used to | ||
create the basic car in steps (1) and (2). Make sure that these accessories are proportional in size to the original Simple | create the basic car in steps (1) and (2). Make sure that these accessories are '''proportional''' in size to the original '''Simple | ||
Car. | Car'''. | ||
(6) Have each individual (or group), in turn, attach their accessories to the Simple Car model using tape, and have them assign | (6) Have each '''individual''' (or '''group'''), in turn, attach their accessories to the '''Simple Car''' model using tape, and have them assign | ||
their creation a logical name. For example, if the accessory was a blue shell for the car, a fitting name would be Blue Car. | their creation a '''logical name'''. For example, if the accessory was a blue shell for the car, a fitting name would be Blue Car. | ||
(7) Have each individual (or group) explain exactly what it is that they have added the the Simple Car, as well as what features | (7) Have each '''individual''' (or '''group''') explain exactly what it is that they have '''added''' the the '''Simple Car''', as well as what '''features''' | ||
their new creation possesses which were present in the original Simple Car model. Highlight the fact that although the Simple | their new creation possesses which were present in the original '''Simple Car''' model. Highlight the fact that although the Simple | ||
Car has been added to, none of its original features have been removed. As each individual or group leaves, have them remove | Car has been added to, none of its original features have been removed. As each individual or group leaves, have them remove | ||
their accessories so that the next group can go. | their accessories so that the next group can go. | ||
(8) Once all groups have gone, reiterate the fact that although accessories may have been added to the Simple Car basic class, | (8) Once all groups have gone, '''reiterate''' the fact that although accessories may have been added to the Simple Car basic class, | ||
of the features of the Simple Car were removed, and that each derived class, although adding accessories to the Simple Car, | none of the features of the '''Simple Car''' were removed, and that each derived class, although adding accessories to the Simple | ||
Car, still contained all of the features of the original '''Simple Car''' base class. | |||
This exercise provides a concrete, observable example of the methodology behind inheritance, and attempts to present this methodology by engaging students in an enjoyable activity which educates students on a relatively difficult topic, while simultaneously promoting creativity and expression. | This exercise provides a '''concrete''', '''observable''' example of the methodology behind '''inheritance''', and attempts to present this methodology by engaging students in an enjoyable activity which educates students on a relatively difficult topic, while simultaneously promoting creativity and expression. | ||
CREATED BY: Cory Burgett, Nick Forrer, and Mark Etheridge | '''CREATED BY: Cory Burgett, Nick Forrer, and Mark Etheridge''' | ||
Latest revision as of 03:47, 16 April 2008
ACTIVE LEARNING EXERCISE 2: INHERITANCE
Arguably one of the most powerful features of any object-oriented language is that of inheritance. This feature allows the programmer to define a basic object type (the base class), and then extend that object and its functionality in further classes (derived class). The derived classes contain the same variables and functions of the original class, but allow the programmer to extend the original functionality to whatever degree is necessary, without actually changing the functionality of the original base class. Unfortunately, it is often the case that beginning programmers have a difficult time fully grasping the concept of inheritance, despite its applicability and usefulness. This exercise will present a fun and engaging method for representing a more concrete example of the inheritance process, and will hopefully lead to a more comprehensive understanding of the inheritance process.
- NOTE: The base object used in this example will be a car; however, you can make your base class anything that you want, as long as it is within the scope of the exercise.
(1) Obtain a piece of cardboard (or poster board) of reasonable size, and cut it into the shape of a basic car chassis.
(2) Using markers or crayons, add some basic details to the car shape, and for each detail, write a description on the related part of the car. For example, if we assume that our car has an engine, we will draw an outline of an engine, on the shape we just drew, we will write "engine." This is for concreteness' sake, so that participants in the activity will have a visual indicator of each of the features of the Simple Car.
(3) Add a few more details and descriptions in order to give a basic layout for our Simple Car. This car will represent our base class, with each of the labeled features representing individual variables and/or methods.
($) Attach the basic car model to the wall or a white board using tape, so that the class can see it clearly.
(5) Have each student (or group of students, depending on class size) come up with some sort of accessory or improvement which they would like to add to the basic car. Have them draw and label these accessories on paper, similar to the method used to create the basic car in steps (1) and (2). Make sure that these accessories are proportional in size to the original Simple Car.
(6) Have each individual (or group), in turn, attach their accessories to the Simple Car model using tape, and have them assign their creation a logical name. For example, if the accessory was a blue shell for the car, a fitting name would be Blue Car.
(7) Have each individual (or group) explain exactly what it is that they have added the the Simple Car, as well as what features their new creation possesses which were present in the original Simple Car model. Highlight the fact that although the Simple Car has been added to, none of its original features have been removed. As each individual or group leaves, have them remove their accessories so that the next group can go.
(8) Once all groups have gone, reiterate the fact that although accessories may have been added to the Simple Car basic class, none of the features of the Simple Car were removed, and that each derived class, although adding accessories to the Simple Car, still contained all of the features of the original Simple Car base class.
This exercise provides a concrete, observable example of the methodology behind inheritance, and attempts to present this methodology by engaging students in an enjoyable activity which educates students on a relatively difficult topic, while simultaneously promoting creativity and expression.
CREATED BY: Cory Burgett, Nick Forrer, and Mark Etheridge