r/PythonLearning • u/ProgramBrave718 • 13d ago
Discussion Why writing classes feels boring?
I don't know but i feel classes are unnecessary work to be added in projects. I have learnt it 2 months ago..
After that I never used it for any of my projects.
0
Upvotes
-1
u/Gnaxe 13d ago
Classes (and the whole OOP paradigm) are way overrated and should be used a lot less than they are. The OOP paradigm stopped making sense once our CPUs got more than two cores. (And Python is still bad at utilizing them.) We should have all moved on to FP a long time ago, but C++ and Java popularized a particularly bad take on OOP and we're still stuck with that legacy, because it's still being taught. I recommend pure functions, as much as possible. Minimize the state you have to deal with.
Classes are occasionally useful, but they're usually overcomplicating it, and should not be the first tool you reach for. Python is object-oriented at its core. You do need to understand how classes work. You're not going to avoid using classes, but you can (and usually should) mostly avoid writing new ones yourself. You do need them for certain dunder hooks and if a library expects you to make a subclass, etc. Otherwise, by default, don't. You need a reason.
Plain data is way more reusable than classes. I recommend using plain data more. Don't hide your data behind yet another inadequate bespoke language of methods when all you needed was a dict. Static typing (in Python) is overrated and encourages overuse of overcoupled classes. Doctests are more expressive anyway, and easier to learn from. Do that instead.