DEV Community

SheetsC
SheetsC

Posted on

Flatiron Phase-3

This instance of a blog has to do with the transition my cohort and myself are facing.
-The challenges of moving from JS to Python.

Object Orientation (OO) is something that is not unique to Python, it gives the programmer more functionality and the ability to cut down on repeated code. A simple way to explain OO is to think of the world as full of Instances like "Lights, Cups, Food" a LED light is an instance of something that belongs in "Lights" and has special attributes. LED light instances are LED light objects, meaning an Object that is a key: value pair in JS is now referring to a single entree of a more global term. This global term is referred to as a Class. To keep with the example a LED light is an object with the class "light".

Speculating on OO and that it can be applied to JS I find myself questioning the meaning of these objects in OO how to relate them to Objects of JS. With our LED light in our hand.. can this be thought of as a key of our LED light and a value that points to the class which it belongs to?

list = ["LED", "incandescent", "black_light"]
Enter fullscreen mode Exit fullscreen mode

The instance LED has a class "str" is it wrong to think that this LED can be represented as LED: "str?
I probably have this complete wrong here and desperately need to rethink the concepts.

Anyway, with OO we are able to define the class "light" and its methods... this is extremely valuable when we have a vast list or dictionary of many instances of the same or even different classes. Something that is not unique to our LED light is that it can turn off and on... we want to be able to turn off/on all the lights that we are working with regardless if they are the LED in our hand. We can define the "light' class so that there is a turn off/on method for every instance we have of a "light".
This is all fine and dandy but when we are dealing with many, many classes and we are in different files days after initially writing the class is there a way to list the methods defined for the class? I was just found told the best practice is to search through the files manually to avoid inheritance issues.

Top comments (0)