Module 4 Lesson 1: Intro to OOP (Thinking in Objects)
·Programming

Module 4 Lesson 1: Intro to OOP (Thinking in Objects)

Change the way you solve problems. Learn the philosophy of Object-Oriented Programming and why it’s the secret to building massive apps.

Module 4 Lesson 1: Intro to OOP

Up until now, our code was like a list of chores: "Do this, then do that, then find this." This is called Procedural Programming. But as programs get bigger—like a video game or a social network—this approach gets messy.

Object-Oriented Programming (OOP) is a different way of thinking. Instead of lists of commands, we build our programs out of "Objects."

Lesson Overview

In this lesson, we will cover:

  • The Philosophy: What is an object?
  • Attributes and Methods: Data and Actions.
  • Classes vs. Objects: The Blueprint vs. the House.
  • Why use OOP?: Scaling and organizing complex software.

1. What is an Object?

In the real world, everything is an object. A Car is an object. A Dog is an object. Even a User Account is an object.

Every object has two things:

  1. Attributes (Data): Things the object has. (e.g., A car has a color, a model, and a speed).
  2. Methods (Actions): Things the object does. (e.g., A car can start, stop, and accelerate).

2. The Blueprint Analogy

Imagine you want to build 100 identical houses. You wouldn't want to draw a new plan for every single house. Instead, you draw one Blueprint and then use it 100 times.

  • The Class: The Blueprint (The idea of a house).
  • The Object: The actual House (A specific building on a specific street).

In Python, we write a Class to define what an object should look like, and then we create Instances (Objects) from that class.


3. Procedural vs. OOP: A Visual Comparison

Procedural (Module 1-3):

"To drive the car, check if there is gas, then turn the key, then press the pedal."

OOP (Module 4):

"Tell the Car Object to start() and then tell it to drive()."

By grouping data and actions together into one "Object," we make our code much easier to manage. If the start() logic changes, we only have to change it once inside the Car Object!


4. Why Does Industry Use OOP?

  1. Reusability: You can use the same "User" object in your login screen and your profile screen.
  2. Scale: It’s easier for 500 developers to work on a game if one team handles the "Player" object and another handles the "Enemy" objects.
  3. Real-world Modeling: It's more natural for our brains to think about "Customers" and "Orders" than a giant list of variables.

Practice Exercise: The Object Brainstorm

Pick a real-world object (e.g., A Video Game Character, A Smartphone, A Bank Account).

  1. Identify 3 Attributes (Data) the object has.
  2. Identify 3 Methods (Actions) the object can do.

Example: Phone

  • Attributes: model, battery_level, is_on.
  • Methods: make_call(), send_text(), recharge().

Quick Knowledge Check

  1. What is the main difference between an "Attribute" and a "Method"?
  2. In the house analogy, which one is the "Class"—the blueprint or the house itself?
  3. Name one benefit of using OOP for large software projects.
  4. Can an object exist without a class?

Key Takeaways

  • OOP focuses on "Objects" rather than "Procedures."
  • Classes are templates (blueprints); Objects are instances.
  • Objects combine data (attributes) and behavior (methods).
  • OOP makes complex code more organized and modular.

What’s Next?

We understand the concept. Now let's see the code! In Lesson 2, we’ll learn how to write our very first Class and create Objects in Python!

Subscribe to our newsletter

Get the latest posts delivered right to your inbox.

Subscribe on LinkedIn