I like to check quite advanced concepts early on to understand the kind of things I am moving towards. I have always heard about “object oriented programming” and it sounds cool and seems to be pretty hard. I wanted to understand a bit more what it actually means.
While researching on this I found two channels that look super interesting. One about programming, the other about finance.
- thenewboston – Python Programming Tutorials – About programming, and I am liking it so much that for sure I will take the python one.
- martinshkreli – Introduction to investment and Finance– That evil guy (is he in jail?) but fucking smart – I expect his finance lessons to be top! Might follow them, or might not.
Back into classes, objects etc.
Well, athough I am not clear exactly what they are, I think I understand the basic concept. A class is basically you define “something” that will have a series of “attributes”. You can then create “objects” from that class, which become independent beings. For example, there can be a class “Car” that has attributes, color, engine, etc… and then you can create many cars (objects) with different attributes. The interesting thing is that you can create functions for a particular given class, so that later you can use them for that class only!
Whenever you create a function inside of a class, the function has to be launched with respect to an “object”. Because at the beginning you are defining the function and you are not applying it to any object, that is why in the parameter you need to put “self”. Self is just basically a substitue for the place where the name of the object will go later!