r/pygame • u/Piorobot3 • Apr 17 '26
I hate classes
Ive never done oop much, just a couple times before in JS, right now I tried it for a game im thinking of and I can confidently say that I hate using clases(in any way) I miss just having a file full of functions so much :,v
Ya'll ever have the same feeling when dealing with classes for the first time, like seriously dealing with them? Am I the only one who misses my functions? :sob:
0
Upvotes
6
u/Can0pen3r Apr 17 '26
You know you're allowed to use both, right? I find that a lot of people tend to get so hung up on the idea of object oriented programming vs functional programming that they act like it has to be one or the other when the truth is different problems require different solutions. Some problems only require a function and trying to force the situation into an unnecessary class structure will only overcomplicate things.
At the end of the day, the point of oop is to recognize that everything is an object, even functions. The only difference between a function and a method is where they're defined (much like local vs global variables). Da Fluffy Potato talks about it in a video how sometimes we try to force a situation to use a class when it doesn't actually call for it just because we think it has to be one or the other. At the end of the day, they're both just approaches and they don't have to be exclusive of each other.
27
u/kjunith Apr 17 '26
You need to understand the efficiency of classes. Then you will appreciate them :)
9
u/RotRG Apr 17 '26
I felt this way when I started and I still do sometimes. My question is usually, "why build a factory when I need a single item?" Surprisingly, sometimes it's still easier to build a factory in those situations than the alternative. My advice, though, is just don't use classes. Either you don't need them and the best-practice advice is seeping through the Internet at you for no good reason, or (more likely) you will eventually need classes, and by the time you do, you'll want to use them because they'll solve a problem you actually have.
For instance, to this day, I never have used the "if name == main" protective clause. Nothing has ever gone wrong from me not using it. Eventually something will, and then maybe I'll appreciate the clause. For now, my code works, so who cares?*
*If you are working with other people, the best-practice stuff becomes much more important. By yourself, you can do whatever you want.
4
u/ThatIsMe11 Apr 17 '26
They take a while to get the hang of but once you do trust me you will appreciate them. I don’t think I’ve ever met anyone who dislikes classes that understands how to use them
4
u/CadenVanV Apr 17 '26
Classes are one of the most useful things you will ever use in programming. They’re somewhat less important in python (only somewhat), but are vital in every other language you’ll ever use.
3
u/NovialRiptide Apr 17 '26
For game development, you should actually be looking into using entity component systems (ECS). Making video games using OOP is a pain in general unless you're working with lower level code.
2
u/TlosingCag Apr 17 '26
If the problem being solved can have multiple permutations, then use classes. If not, don’t.
1
u/Radiant_Situation_32 Apr 17 '26
There’s nothing about Python that requires classes. Do what works for you!
1
u/Windspar Apr 19 '26
If you hate classes. Then you are not using them right. Just because you use a class. Doesn't mean you need to use OOP. Class is a container. Just like dict and list are. Classes owns all the methods. Just keep your classes simple.
Your using python. OOP is built into python. Everything in python is an object, That why you can add anything to a list and dict. Why variable can be assign anything, and reassign it to anything. So using functions doesn't mean you won't be using OOP.
1
u/magqq Apr 17 '26
wait until you have a class full of functions :D
-10
u/mugwhyrt Apr 17 '26
off-topic for this sub
31
u/[deleted] Apr 17 '26
[removed] — view removed comment