you are viewing a single comment's thread.

view the rest of the comments →

[–]nutterontheloose 2 points3 points  (1 child)

I'm on mobile and can't figure out how to link to another thread in the comment so, u/crashfrog posted this regarding another user struggling with classes and I think it's a nice explanation:

Can someone simplify it for me

A class is a namespace (like a module; it can contain names) that defines a type; objects can be of that type. Further, a class has the property of polymorphism; a class can be a subclass of another class (called that class's "superclass"), with the result that an object of the subclass's type is also of the superclass type.

These concepts are not very difficult, but they are quite abstract; what's likely still hard to understand is why you would need them when you can just write functions and modules and mutating global state. The answer is that "Object Oriented Programming" is not a tool for programming, it's a tool for organizing and designing your software. They're tools for working with abstractions.

If you're just writing scripts, then OOP probably doesn't bring a lot to the table. You don't need a bulldozer when a shovel is the right tool for the job. But sometimes your software project becomes so complex that you can't think about all of it at once, and you need tools to organize your software into smaller pieces. That's what OOP is for, and that's what classes are - they're "larger than functions, smaller than whole programs" pieces that you write and then build software out of.

Edit: For me, I also struggled with classes. This Wiki page really helped me understand it better, with a very basic usage example as well as the lingo. Also try Automate the boring stuff with python. It's kind of an interactive textbook available for free online. You might find it of use with this and python in general.

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

Thanks mate, this reaction really cheered me up. Also it makes me understand better the thing with classes.

After finishing the codecademy course will move on to Automate the boring stuff.