Learn creative coding writing simple programs

104. OOP means Object Oriented Programming

Object Oriented Programming is a technique that helps us divide programs into smaller parts using something called Classes and Objects. Cars, trees or people can be Objects. Each object in an instance of a Class. The Class is like the recipe used to build each Object. You use the same Class to build different instances of one kind of Object.

Imagine you want to create cars. To create car A you take the Car Class and create your first car by using new Car(). When you want a second car (car B) you take the same Class and create a new instance. You can use different Classes to create different kinds of objects. In this episode we only have one Class, called Car.

Each created object (each car) has properties and methods. Properties are things like color, amount of doors, brand and model. Methods are things the Object can do. For example a car can start, stop, change speed and open doors. Our simple car can only do one thing: drive().

Tags: oop, class, object, instance

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
Do `float` and `int` smell similar?
To highlight code blocks, surround it with ``` code-fences ``` like this:
``` void setup() { size(600, 600); } ```