Intro: Object Oriented Programming: Creating Objects Learning/Teaching Method/Technique Using Shape Puncher
Learning/teaching method for students new to object-oriented programming. This is a way to allow them to visualize and see the process of creating objects from classes.
1. EkTools 2-inch large punch; solid shapes are best.
2. Piece of paper or cardstock.
Step 1: Object Oriented Programming Definitions
1. A "class" is defined as the piece of cardstock/paper.
2. The action of punching out a piece of the cardstock/paper with the shape puncher is known as "instantiation" or "creating an instance of the class".
3. Each of the pieces that have been punched out are known as "objects".
4. The different things written on each of the pieces of paper are the objects' "attributes", ie: variable and method names creating custom objects.
Step 2: Identify the Class
1. On your piece of cardstock/paper, write down the class name.
2. In this case, we are calling the class "Orange".
3. Next, add a variable and a method that will become part of the objects created from the class.
Step 3: Create/Instantiate the Object
1. Using the 2 inch hole punch, cut out several shapes.
2. The act of cutting out shapes is known as creating an object, or "instantiation", that is, the creating of an instance of the class.
3. Here, we have punched out several shapes, each one an object of class "Orange".
4. Each object will have the attributes of the class.
5. Note: If it helps with visualization of creating objects, turn the punch over and cut out the shapes with the underside facing up so that you can see the object being created and cut out from the cardstock/paper.
Step 4: Name the Objects
1. Name each of the objects by writing them on the shapes with the pen.
2. Here, they are named "NavelOrange", "ValenciaOrange" and "BloodOrange" and "Clementine"
Step 5: Give the Objects Attributes
1. Each object has the attributes of class "Orange".
2. Give each of the objects the class attributes (variable/method names) by writing them on each of the objects to customize each object.
3. Now, one can visualize and touch each each custom object created from the same class with a different name and with class attributes for each custom object.
4. For example, here we have created an custom object called "NavelObject" from class "Orange", with the attributes "Variable: Ripe" and "Method: PickFromTree".