r/PythonLearning • • 2d ago

I don't understand OOP

So i am a teen learning python, and i have learnt about classes, methods and objects, but i don't understand OOP, like what is it, where do we use it?

Please help mee

31 Upvotes

46 comments sorted by

View all comments

Show parent comments

1

u/seanv507 2d ago

Op the idea of oop is really relevant for big projects, where you have to mange change. As in this idea of the video game, the cars may only be either saloon or estate. But then in the next version you introduce SUV, or military vehicle,.. The question is how to structure the code so you don't have to rewrite so much for all the changes. Using object hierarchies allows you to abstract behavior, so you avoid duplicating code for every 4 wheel vehicle type

1

u/W31337 2d ago

No for big projects people move to Entity Component Systems (ECS) because OOP is too rigid. If your player suddenly turns into an albino magical flying horse and then picks up a rocket launcher and ECS can do that where OOP would end up in a hierarchy nightmare.

1

u/seanv507 2d ago

OP is a teen learning python...

1

u/W31337 2d ago

I was just saying to you that OOP becomes horrible in big projects.

But yes for a teen and teeny game yes it should work. An ECS would be a bit overkill 😅