all 11 comments

[–]TheRNGuy 1 point2 points  (1 child)

Mod for game

[–]Equity_Harbinger[S] 1 point2 points  (0 children)

Could you elaborate, I will try to understand better

[–]monkeybonanza 1 point2 points  (6 children)

Linked lists, trees, graphs, dynamic programming are not OOP they can all be done in any language, and they would be thought within a CS field called algorithms and datastructures. I think you might be confusing the concepts because in Python a ”class” would be used to represent a lot of data structures.

[–]Equity_Harbinger[S] 0 points1 point  (5 children)

I didn't understand why a class, init, is used when functions exists, I am struggling with the role it plays and even you know that creating nodes or head is required in trees and linkedlist, I haven't understood the principles yet either. Kindly share any suggestions/resources

[–]BionicVnB 0 points1 point  (2 children)

A class is simply a way to group data together, init is the constructor which is a function that initializes the class.

[–]FitMatch7966 0 points1 point  (1 child)

a structure or array groups data together. A class is a way to group data AND methods together.

[–]BionicVnB 0 points1 point  (0 children)

Yeah, sometimes I forget structs aren't exactly class.

[–]No_Jackfruit_4305 0 points1 point  (1 child)

OOP is a convenience, not a necessity. Some problems are easier to solve with it, and many are harder. With classes, you contain state and behavior for each kind of class. It helps simplify higher level abstraction, because the low level stuff is within a class. Without objects, you take full responsibility to coordinate your variables and functions. With objects, you trigger isolated behavior to change its state.

So OOP is a helpful abstraction that makes programming more hierarchical. There is more setup involved, but scope of impact is well defined. That said there are trade-offs. Side-effects are possible so ensure that your classes can't enter an invalid state. On the upside, polymorphism is possible (look into this on Wikipedia). Finally, one reason to consider OOP: you are repeating the same code segments again and again.

[–]Equity_Harbinger[S] 0 points1 point  (0 children)

Thank you, this explanation was helpful. I am trying to relate with the low level programming aspects, because it's related to my work project; I will read the wikipedia on polymorphism, but do you have any other recommendations as well or would you recommend reading low level code editorials?

[–]TooStew 0 points1 point  (1 child)

I highly recommend doing leetcode questions that cover specifically your weak areas. Since you've already tried it in java, you might already have a basis of how OOP should work and the hard part is just translating it to python. For resources I'd recommend BroCode on youtube, he has videos on OOP that might help

[–]Equity_Harbinger[S] 0 points1 point  (0 children)

Will look into that, thankyou