NOTE: Learn more about properties and other concepts on your teacher dashboard. Each unit has an overview that explains the concept in detail. https://dashboard.kodable.com/#/curriculum/10
Definition: Properties are features that describe an object. This defines what an object looks like and does in a program, and is what the user sees.
Example: We’ve talked about vehicles as our example of a class in object-oriented programming. We talked about properties of all vehicles being certain things that all vehicles have, like wheels, brakes, a steering wheel, and an engine. These are all properties of vehicles.
Another property that all vehicles have is color. The color, like other properties, can differ between cars that are the same make and model, without changing anything else about the car during the production process. The automakers don’t have to start from scratch to make the same car in blue, white, or gray. They can easily make the exact same car in a variety of colors. This would be like editing the color property value on a car in a program.
Remember when we talked about variables? Properties are special types of variables that are associated with an object. Properties are assigned to a class when the class is defined, and their values can be modified on individual objects. Modifying properties of an object will make the object different from the main class and any other objects. You can add or delete properties, but all objects will automatically inherit the properties of the main class when they are created.
In Kodable’s independent practice lessons in Bug World, students will have a property editor that they can use to change values of properties on their towers they create from the tower class. The property editor shows what the properties and values of the class are. As students advance through Bug World, they will earn new properties, which will allow them to make their new towers different and have more capabilities.
In this properties independent practice lesson, students create a new tower a property editor appears. This prompts students to change the value of the range property of their tower. This change does not affect ALL towers in the BlueBlaster class; editing the property values on an object only changes that one object. We see that there are strength and speed properties. Students gradually unlock the ability to edit these properties to increase the strength or speed on the selected object.
When we learned about classes, we talked about how our programmers at Kodable use a class called “Command class” to create the blue command arrows from in the Smeeborg independent practice lessons. The Kodable arrows are all written the same way in code, and have a property for “direction” and “image”. When our programmers edit the value on direction, it will change which way the arrow is facing. When the image property value is changed, it changes what the arrow looks like, so it’s pointing in the correct direction. Editing these two property values doesn’t change anything else about the arrows- they are still all the same color, shape, size, and have the same functionality like being dragged, dropped, or deleted.
Why We Use Properties: Objects can’t exist without properties! Properties are what make objects different from each other. This makes it possible to create programs that can have a lot of different objects and interactions for the user.