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

by matt392 in Circuits > Software

1154 Views, 17 Favorites, 0 Comments

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

56a1a1c3937ddbc2b200046c.jpeg
55d8e19450e1b6c71f0009a8.jpeg

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.

Create the Base Class

55d8e3364fbade3ab600027f.jpeg

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".

Draw Out Objects

55d8ed7067400ce1a8000005.jpeg
55d8edd467400c1450000061.jpeg

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

Create the Objects

55d8eec9937ddbfe35000a43.jpeg
55d8ee3a67400c1450000062.jpeg
55d8f20145bcebdeeb0001ad.jpeg

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".

Name and Define the Base Class Objects

55d8e29a4fbade6ede0009f6.jpeg
55d8e51015be4d2b3f000329.jpeg

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".

Define the Derived Class

55d8e40e67400cbbcc001294.jpeg
55d8ef214fbade6ede000a33.jpeg

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".

Create Boxes in Derived Class

55d8ef7050e1b6c71f0009d3.jpeg
55d8efa750e1b68ba7000180.jpeg

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.

Create the Objects of the Derived Class

55d8efd915be4d2b3f00035d.jpeg
55d8e34e67400cbbcc00128d.jpeg
55d8f08f2e7fb604040009df.jpeg

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".

Name the Derived Class Objects

55d8f10750e1b6c71f0009d8.jpeg

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"

Add the Derived Class Properties

55d8e5bb15be4d2b3f00032c.jpeg

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

Add the Base Class Properties

55d8f15450e1b6c71f0009d9.jpeg

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

Place Objects Next to Cardstock

55d8f1672e7fb604040009e6.jpeg

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.