Introduction: Object Oriented Programming: Class Inheritance Learning/Teaching Method/Technique Using Scissors

Picture of Object Oriented Programming: Class Inheritance Learning/Teaching Method/Technique Using Scissors

Learning/teaching method for students regarding class inheritance within object oriented programming. This is a way to visualize and see the process of creating objects from base classes and derived classes.

Parts:
1. Scissors (any kind will do).
2. Piece of paper or cardstock.
3. Pen (marker may create too thick a line).
4. Ruler or other straightedge.

Definitions:
1. A "class" is defined as the piece of orange cardstock/paper.
2. The action of cutting out a piece of the cardstock/paper with the scissors is known as "instantiation", "creating an instance of the class" or creating an object.
3. Each of the pieces that have been cut out are known as "objects".
4. The things written on each of the pieces of paper are the objects' "attributes" or properties, ie: variables and methods for that object.

Step 1: Create the Base Class

Picture of Create the Base Class

1. Using the pen and cardstock, create the Base Class
2. Here, we are naming the Base Class "Orange", a variable called "Ripe" and a method called "PickFromTree".

Step 2: Draw Out Objects

Picture of Draw Out Objects

1. Using the ruler or straightedge, draw 2 boxes under the Base Class.
2. These are going to be the objects of the class.

Step 3: Create the Objects

Picture of Create the Objects

1. The act of cutting out shapes is known as creating an object, "instantiation", or the creating of an instance of the class.
2. Here, we have cut out 2 shapes, each one an object of class "Orange".
3. Each object will have the properties of the class "Orange".

Step 4: Name and Define the Base Class Objects

Picture of Name and Define the Base Class Objects

1. Name the 2 objects using the pen.
2. Here, we are calling them "ValenciaOrange" and "BloodOrange".
3. Identify the class from where they were cut from. In this case, it is "Orange".
4. Note the variable and the method of the class from which the objects were created. Here, the variable is "Ripe" and the method is "PickFromTree".

Step 5: Define the Derived Class

Picture of Define the Derived Class

1. Using the ruler or straightedge, create a large box under the Base Class and the objects that were cut out, large enough to hold 2 objects.
2. Inside the new large box define the Derived Class by writing the Derived Class name, variable and method.
3. In this case, we are calling the class "OrganicOrange".
4. The variable is "Shiny" and the method is "PeelSkin".

Step 6: Create Boxes in Derived Class

Picture of Create Boxes in Derived Class

1. Using the straightedge or ruler, create 2 smaller boxes within the within the the Derived Class box under the class properties. Make them a little bigger than the 2 object boxes above.

Step 7: Create the Objects of the Derived Class

Picture of Create the Objects of the Derived Class

1. Using the scissors, cut out each square from the sheet/cardstock.
2. The act of cutting out shapes is known as creating an object, "instantiation", or the creating of an instance of the class.
4. Here, we have cut out 2 shapes, each one an object of the Derived Class "OrganicOrange".
5. Each object will have the properties of the Derived Class "OrganicOrange" and the Base Class "Orange".

Step 8: Name the Derived Class Objects

Picture of Name the Derived Class Objects

1. Name each of the Derived Class objects.
2. Here, we are calling them "NavelOrange" and "Clementine".
3. Next, note the class from which the objects are created. In this case, it is "OrganicOrange"

Step 9: Add the Derived Class Properties

Picture of Add the Derived Class Properties

1. Write down the properties which come from the Derived Class.
2. In this case, the variable is "Shiny" and the method is "PeelSkin".

Step 10: Add the Base Class Properties

Picture of Add the Base Class Properties

1. Finally, add the Base Class properties which were inherited from the Base Class as a result of the objects being created from a Derived Class.
2. In this case, the variable inherited from the Base Class "Orange" is "Ripe".
3. The method inherited from the Base Class "Orange" is "PickFromTree".
4. Circle the inherited Base Class properties to mark them as coming from the Base Class to make it clear on the object from where they came.
5. Note that those properties came from the Base Class

Step 11: Place Objects Next to Cardstock

Picture of Place Objects Next to Cardstock

1. Take the 2 objects created from the Base Class ("Orange") and put them next to the cardstock from which they were cut out of. Be sure they are next to the area of the cardstock from where they were cut out in the Base Class area.
2. Place the 2 objects from the Derived Class ("OrganicOrange") next to the cardstock from which they were cut out of. Place them next to the Derived Class area of the cardstock.
3. Now, a student can visually see the objects in a physical sense, as well as view directly which classes they come from and how each has come to pick up their properties.

Comments

About This Instructable

525views

15favorites

License:

Bio: Occupation: Tech Support
More by matt392:Q-Tip Paint PenReplace Letters on Computer Keyboard (or Make Bigger Letters) With Nail PolishMulti-bit Screwdriver From PVC Pipe
Add instructable to: