Just finished a lesson on Object-Oriented Programming and I’m hyped. This is one of those concepts that separates “I can write code” from “I can build systems.”
Four pillars, one example — a course/student system:
class Course:
def __init__(self, title, price):
self.title = title
self._price = price # encapsulation — protected from outside tampering
def get_price(self):
return self._price
def describe(self):
return f"{self.title} — ${self._price}"
class Student:
def __init__(self, name):
self.enrolled_courses = []
def enroll(self, course):
self.enrolled_courses.append(course)
print(f"{self.name} enrolled in {course.title}") class PremiumStudent(Student): # inheritance — build on what exists
def __init__(self, name):
super().__init__(name)
def enroll(self, course): # polymorphism — same method, different behavior
self.enrolled_courses.append(course)
print(f"{self.name} enrolled in {course.title} at ${discounted:.2f} (premium rate)") # Abstraction in action — I don't need to know HOW enroll() works, just that it does
course = Course("Python Fundamentals", 199)
regular = Student("Alex")
premium = PremiumStudent("Jordan")
regular.enroll(course)
premium.enroll(course)
Run it and both students enroll — but the premium student’s enroll() behaves differently even though I called the exact same method. That’s polymorphism in action, and it’s the moment OOP stopped being theory and started being obvious.
If you’re working through this stuff right now — trust the process. It clicks harder than you expect.
Drop a 🔥 if you’ve had that lightbulb moment with OOP.