Advice and answers from the Kodable Team

NOTE: Learn more about Classes and other concepts on your teacher dashboard. Each unit has an overview that explains the concept in detail. https://dashboard.kodable.com/#/curriculum/9

A class is a definition of an object. All objects in a program are created from classes and can’t exist without them. Classes can be thought of like a blueprint, or a template to create new objects.

Definition: Information that describes the details of an object in object-oriented programming.

Example: In our Object-Oriented Programming video), we talked about how OOP mirrors the way objects interact with each other to do things in the world around us. We talked about vehicles, and how cars and trucks are subclasses of the Vehicle class. Let’s talk about how we can use the vehicle class to understand how classes are used as blueprints to create new objects.

We know that all vehicles, like cars, trucks, vans, and sports cars share fundamental similarities that make them vehicles. They all have wheels, an engine, brakes, and the ability to drive.

Picture yourself at a car dealership and think about every one of those shiny new cars on the lot. Automakers don’t start from scratch to design a new vehicle, like thinking about how it will steer, stop, run, or move. This is already defined and used over and over again to produce new vehicles. Automakers essentially already have a blueprint to create a new object from, which can be modified or tailored to produce a specific make or model of a car.

Application: We know that in programming, classes are used as blueprints, or templates, to create new objects from. In Kodable’s on-screen practice in Bug World, students see the actual JavaScript code that defines the Tower class they are working with.

In the code for the Tower Class, students will see the name of the class, properties of the class, and functions of the class. Students are able to create new objects from the class, and see the JavaScript code with each step in the process.

In this lesson, there are different types of slimes that move at different paces coming toward the fuzzFamily. Students need to choose the flamingo class, mighty gnome class, or shield class to build new towers from. Each of these classes have different properties, so students need to think critically about the properties of their classes and choose to build towers that will best defend from the fast and slow moving slimes.

In the actual code, our programmers wrote for Kodable’s on-screen independent practice mazes in Smeeborg, the direction arrows are all in the Command class. Every object in the Command class has the ability to be dragged, dropped, or deleted. Each arrow has a different direction and image property, which makes them look different and makes the Fuzz move the correct direction when the user selects the command.

Why We Use Classes: A class gives a programmer a simpler interface to a complex object while giving the user a common interface to use. Think back to our vehicle example: A driver can get into any car and expect the steering wheel to be in the same location, the brake pedal to be on the left and the gas to be on the right. Without classes, we couldn’t do anything in OOP! We need classes to define what objects look like and what they do in our programs.

Did this answer your question?