Hey friends, Happy Monday!
OOP, object-oriented programming, is the number one topic that you keep asking for in the comments. A lot of people get it as a question in interviews, and I would say it is the most confusing topic in Python.
After a small break, I’m really happy to continue my Python course with the advanced topics, and we start with this big one.
But don’t worry, we don’t start with the syntax. We start with a page of code like this one:
You have many functions that call each other, and many variables in between. And if you want to change something, good luck.
This is very normal in real projects, and OOP is how we organize this page.
Here is the story of OOP, with my sketches:
What is OOP: a programming style, and where its name comes from.
Why OOP: four reasons, from one page of code to a whole team.
When to use OOP: the use cases from my real data projects.
And at the end, you get a short answer for the interview.
Let’s go.
What is OOP
OOP is a programming style. You organize your code into objects, and each object brings the data and the functions together in one place.
And it is only one of many styles.
From left to right:
Procedural: you think in steps. Your code is a list of instructions, and Python goes through it from top to bottom.
Functional: you think in functions. Each function has an input and an output, and the functions hand the data from one to the next.
Object-oriented: you think in objects. You take one object, like the customer, and you put all its values and functions around it.
The idea is not new. It is from the 1960s, and other languages like C++ and Java support it as well.
People said: you know what, we always program around the steps and the functions. But real applications are always about objects, like the customers, the products and the orders.
So they imagined the customer as a circle, with all its values and functions around it. Then another circle for the products, and one for the orders.
With this, the programming is built around the objects, and that is why we call it object-oriented programming.
And the good news is that in real projects, we usually use all three styles.
Why OOP
Now you might ask: why should we program around objects? We were happy with the functions.
There are a lot of reasons. Here are four of them, from your own code up to the whole team.
Reason 1: Organize the chaos
As your code gets bigger, you get the feeling that you write the same steps over and over. We know the solution already: put those steps inside a function, and call it from anywhere.
With that we have only one place for the logic, the code gets shorter, and you can change it very fast. So functions are amazing.
But over time your code keeps growing, and using only functions will not help. Then you have the page from the start of this issue, and the same question: which functions belong together, and which variables do they need?
So how do we get more organized? Now look at the same page again.
Some functions and variables always deal with one specific thing, like the customer, the bank account or the connection to the database. We call it an entity.
The customer is even there twice: one of its functions is at the top of the page, and the other one is at the bottom.
And the idea is very smart and simple. How about we put everything about one entity into one box, and we give the box the name of the entity?
So now things are way more organized. If I want to do anything with the customer, I have a full box of tools for it.
It is like the tools in your basement: you have to start organizing them, and put them into categories with labels.
The fancy names
Of course, in programming we always need fancy names. We cannot just call it a box.
The box is a class. A variable inside the class is an attribute, and a function inside the class is a method.
To use a function, you just call it by its name. With a class there is one extra step: first you create an object of the class.
Here the variable maria is one customer. She is an object of the class Customer, and we also call an object an instance of its class.
It is like the class tells her: you are one of us now, so you can use our tools.
And she uses them with a dot: maria.clean_name().
Those are the four words of OOP: class, attribute, method and object.
Reason 2: Standards and rules for the team
We don’t use OOP only to organize the chaos in our own code. There is something way more important: it brings standards and rules to the project.
This is especially important if you work in a team.
Let’s say one developer has to deal with the customers. So this developer creates the variables name and age, and a function to clean the name.
Later a second developer joins the project. She has to deal with the customers as well, but she is not aware of the code of the first developer.
So she calls the variable full_name, she adds a balance, and she writes her own function to clean the name. Then comes a third developer, and it is the same story.
Now look at the three files. We clean the name of the customer three times, with three different functions.
We have two names for the same value. And one customer is -4 years old, because nobody checks the age.
Ask the three developers what a customer is, and each one explains it differently.
So we lost the standards, and we don’t have rules. And this is exactly the moment where we need OOP.
With a class, we define the customer only once, in one place.
In the class we define three things:
The attributes: name, age and balance.
The rules: the age cannot be negative. We write this check only once, inside the class.
The methods: one clean_name() for everyone, and one way to calculate the balance.
And the class itself is only a blueprint of how a customer is defined. It has no customer data inside it.
If you want a customer, you create an object from the class, like “maria” and “sam”. We usually create many objects from one class, and each one has its own values.
You can use your object how you want in your code. But of course, you will be following our names, our rules and our methods.
So we brought standards and rules to the project, and there is no more confusion about what a customer is. And if a rule changes tomorrow, you change it in only one place.
Reason 3: Plug and play for new developers
The life of the developers gets way easier as well. When someone new joins the project, you just say: we have a class Customer, create an object of it, and use its methods.
It is like plug and play. For the new developer the class is a black box: they know the tools and what each one does, so they can start right away.
And you know this feeling already. You call upper() for a string all the time, and you never saw its code.
Reason 4: Split the work by entities
OOP goes deeper, into how we organize the work in a project. You might have a developer with a lot of domain knowledge about the customers, so this developer is responsible for the class Customer.
And another developer has a lot of experience in connecting Python to databases, so she is responsible for the class Connection. And a third developer is responsible for the class of the bank account.
So we don’t split the work only by functions or Python files anymore. We split it by the entities, and this is an amazing way to organize a project.
When to use OOP
And when do you open your Python script and really start to write classes?
Let me show you where I do it in my data projects. It is the same story again, one level bigger: not one page of code, but a whole data platform.
Of course, I don’t expect you to understand every detail right now. Just watch the pattern: something is scattered over many scripts, and then one class brings it together.
Use case 1: Connections
Before: when you build a data platform, like a data warehouse or a lakehouse, the first step is to connect the sources to it. So you write a small Python script for each connection, and with many sources you repeat it over and over.
After: we create one class for each type of connection: the databases, the APIs and the streams, like Kafka.
With that, connecting a new source is really easy. You don’t have to think about all the parameters again, and every connection follows the same standard.
Use case 2: Layers
Before: a data platform has multiple layers, like bronze, silver and gold in the medallion architecture. With a lot of sources and tables, you get a lot of scripts inside each layer, and the same rules keep repeating in them.
After: we create one class for each layer, because each layer has its own rules for the data that enters it.
Now the rules of a layer are written only once, and this is a very famous use case.
Use case 3: Data modeling
This one is less common. In the gold layer you might build a star schema, with one class for the facts and one for the dimensions.
In most projects, people use SQL more than Python for the data modeling. But in a big enterprise lakehouse or data warehouse, you might do it with OOP as well.
Use case 4: Logging and data quality
Before: in data projects and data pipelines we have a lot of extra things, like the logging. And you find the loggers everywhere, around the scripts of every layer.
It is the same with the data quality. We do quality checks left and right, and the way we report the issues is scattered.
After: we create one class for our own logging and one class for the quality checks, as a standard for the whole project.
There are already predefined classes for the logging. But with our own class, it is clear which attributes and methods you can use.
And if anyone wants a new quality check, they create an object from the class and follow the rules there.
This is the whole data platform now, with a class for each part: Bronze, Silver, Gold, Logger and QualityCheck.
We are just trying to bring standards, and to protect the project from chaos.
A function or a class
So we use classes a lot in real projects. But this doesn’t mean that we stop using functions.
Most of the code in a data project is small steps, like reading, cleaning, checking and writing the data. For each step, a function is perfect.
Here is a simple test:
A function: a value goes in, a result comes out, and nothing has to be remembered.
A class: the same values travel from function to function, together with their rules. Then you have an entity, like a customer.
If you are not sure, start with a function. You can easily turn it into a class later.
So …
So is OOP still the most confusing topic in Python?
It is one idea: we put everything about one entity into one box, with its values, its functions and its rules. And we saw it three times: in one page of code, in one team, and in a whole data platform.
And if someone asks you in an interview what OOP is, here is a short answer:
What: a programming style where we organize the code around objects, and not around steps and functions.
Class: the blueprint of one entity, like a customer, with its attributes, its methods and its rules.
Object: one instance of the class, like the customer Maria, with its own values.
Why: it organizes the code, it brings standards and rules to the team, and new developers can start right away.
When: when many parts of a project deal with the same entity. For one small step, a function is enough.
And here is the good news: this is not the first time that you work with classes and objects. You have been doing it the whole time.
Python comes with one class for every data type, like int, str, list and dict. When you write “Hello”, Python creates an object of the class str for you.
That is why “Hello” can use upper(), but not append(). An object can use only the methods of its own class.
This is how Python works: inside, everything is an object.
Python made those classes for us, and now we make our own. This is what we do in the full video: the syntax, your first class, and what Python does with it behind the scenes.
Watch the full video here: [VIDEO LINK]
Thanks for reading ❤️
Baraa
Also, here are 4 complete roadmap videos if you’re figuring out where to start:
Hey friends,
Hey, I’m Baraa, a Data Engineer with over 17 years experience, Ex-Mercedes Benz, where I led and built one of the biggest data platforms for analytics and AI.
Now I’m here to share it all through visually explained courses, real-world projects, and the skills that will get you hired. I’ve helped millions of students transform their careers.

Hey friends —
Hey, I’m Baraa, a Data Engineer with over 17 years experience, Ex-Mercedes Benz, where I led and built one of the biggest data platforms for analytics and AI.
Now I’m here to share it all through visually explained courses, real-world projects, and the skills that will get you hired. I’ve helped millions of students transform their careers.






















The “if you're not sure, start with a function” rule is the most useful line here — it's a decision rule, not just a style preference. And the team-standards argument is what convinced me: three developers, three versions of a customer, and a -4-year-old. The class isn't about elegance; it's about agreeing on what a customer is before the code disagrees for you.