Apply Today to our Software Engineering Program & check out our scholarships!

Back to Setup Page

Connecting OOP to Real-World Scenarios

In the introduction, we shared that Object-Oriented Programming (OOP) is a paradigm for how we can organize code. Without seeing examples, that definition just feels… unhelpful. In this section, we won’t dig into code quite yet, but we’ll do some thinking and list-making to set ourselves up to write code in the next section!

Car Factory

Let’s think about some components of a Ford car factory. We may make some stuff up, but this analogy should help us build context for what OOP is.

  • The factory has a machine that is designed to make a Ford Escape
  • All Escapes have four wheels and four doors
  • The color, interior fabric and engine size can vary from one Escape to another

With the information above, in theory, the manager at the factory should be able to say “please make a blue Escape with a leather interior and 2.5 cylinder engine”, and that should be possible.

That example about the car factory ties directly to concepts of OOP. We will use three main technical terms today. They are below, with the connection to the car factory example:

  • class - A class is like a blueprint or template. The factory machines are designed to make a car - that is the template for ALL Escapes. We could probably name it the EscapeCar class.
  • object/instance - An instance is an object that is made from the class template. The blue Escape that the manager requested (and was able to physically sit in and drive) is referred to as an object or instance of the EscapeCar class.
  • attribute - An attribute is a specific characteristic of an instance. There are two different types of attributes, static and dynamic. Static attributes are the same for every instance of a class. Dynamic attributes change from one instance to the next. With our Escapes, color, interior and engine would be dynamic attributes, because they weren’t programmed into the template, but were extra information the manager was able to give for each specific instance of that class.

Classes and Objects - At Home!

Pick an object that you see sitting around in your home. It could be a candle, water bottle, glove, anything!

Jot down the following, and be ready to share out with the group:

  • What type of object is it? What might the class name be?
  • Are there multiple objects/instances of it in your home, or in the world? List a few.
  • What are some of its attributes?

Are you still wondering how in the world this connects to writing software? That’s what we’ll discuss next!

Next: How to CODE these concepts