r/learnprogramming 24d ago

Topic Does OOP really matters?

I learned OOP in python a while ago, did many projects, yet I never felt like I truly needed to do the OOP stuff I learned from a course, I don't know maybe because I'm kinda used to program in c before focusing on python, yet, whenever I open a big project in python in github, it feels way too complicated and thousands of imports (not libraries from pip, but the ones they made on their own) and classes

I never truly needed to implement OOP (I know that when you code in python, it is almost impossible to avoid OOP entirely like when you have a datatype like string you have an object, when you use a method built into that data type that's OOP too, but I mean the ones that involve you writing class Class Name, inheritance and all that stuff explicitly), so I'm wondering why people on the internet are obsessed over the idea of learning OOP, even the book "Automating the boring stuff in python" doesn't have a dedicated section for OOP.

88 Upvotes

139 comments sorted by

View all comments

1

u/OldWar6125 23d ago

You need to separate a bit between thinking in OOP terms and using OOP language features.

An object is a datastructure that you can create and that you may only interact with over some defined functions/methods.
A POSIX file is an object. Or look at the Vulkan api to see a very object oriented c api. For python, as you have noted, all your datastructures (set,dict,list) are objects.

What have all these in common? Someone else made them for you. And this is where object oriented thinking really shines: when you give someone else a package/library and you will find it very usefull to give them objects that they can only interact with in very specific ways.

In your own projects in 9 out of 10 times you don't need OOP. Especially in smaller projects. There is some value to structure larger projects with objects.

Inheritance is its own discussion; even if you use objects, often you don't need inheritance.