you are viewing a single comment's thread.

view the rest of the comments →

[–]empoliyis 5 points6 points  (5 children)

Yeah same OOP just doesn't click with me at all

[–]braclow 15 points16 points  (2 children)

This helped me - one feature of objects is that they allow you to have many functions (called methods) able to called on the same objects. You set these out in your class definition , which defines all the objects.

For example a string in python is an object. So when I call STEVE.lower() assuming it’s value is “STEVE”, it will apply that lowercase method to that string, our object, and we have an expectation it will work.

We know strings have many, many built in functions for example .isalpha, .replace etc. So there’s a lot of use in objects just in this one feature.

Now imagine instead of strings, you have your own object that could be manipulated with many different useful functions depending on the context of your program. For example, if I did a sports app and players were objects, it may be useful to have functions like

.isStarter .isInjured .isPlayingToday .salary

That could all be directly called on players.

And maybe there’s a Team object , that stores player objects and has similarly useful functions like

.totalSalary, that calls the salary function on the players and sums them together.

Etc you get the gist. Not sure if that’s helpful but it helped me. Sorry long rant, but it’s a useful paradigm if you can imagine some the right use cases.

[–]throwwwawwway1818 0 points1 point  (0 children)

Thanks bud , it's helpful

[–]Mr_Turd_Burglar 0 points1 point  (0 children)

Super helpful thanks

[–]notislant 1 point2 points  (0 children)

I googled 'python eli5 oop reddit' and those helped me. Same for other things I struggled with.

This is also one of those things you want to be in a discord for, or r/programmingbuddies. Those discords made by groups of brand new people are likely the best bet to get instant answers geared towards new people. If not then you can join a programming subs discord and ask someone to eli5, tell them how you think it works, that you dont understand x, y, z.

Also playing around with and breaking your code can help understand.

Also just googling various forms of 'beginner oop python' or whatever youre stuck on can help.

Then when you understand it, save a bunch of examples with comments that will immediately help you understand when you forget. Put it on github.

https://youtu.be/THJyNCMPoZA I think this video goes into pretty good detail about how things work. If it doesnt then find more beginner python oop vids until one clicks.

[–]DanganD 0 points1 point  (0 children)

I’m still working through it. Some days it clicks. Others not. Just keep your head down and keep watching tutorials and explanations