This forum is now read-only. Please use our new forums! Go to forums
Understanding Classes vs Objects vs Instances
This course is gliding by some really fundamental concepts in Object Oriented Programming (OOP) that students really need to understand in order to grok how classes work within the larger framework of how OPP works.
The truth is that object oriented programming often creates confusion by creating a disconnect between the philosophical side of development and the actual mechanical workings of the computer. I’ll try to contrast the two for you:
The basic concept of OOP is this: Class >> Object >> Instance.
The class = the blue print. The Object is an actual thing that is built based on the ‘blue print’ (like the house). An instance is a virtual copy (but not a real copy) of the object.
So when the course inexplicably and without much contextual definition says things like
The first argument init() gets is used to refer to the instance object,
It gets confusing because terminology is being mixed up and combined in unintuitive ways. It helps to think of it like this:
A blueprint for a house design is like a class description. All the houses built from that blueprint are objects of that class. A given house is an instance.
Finally, keeping in mind the following may help with grasping the concept:
The key difference between a function and a class method: A function is floating free, unencumbered. A class (instance) method has to be aware of it’s parent (and parent properties) so you need to pass the method a reference to the parent class (as self). It’s just one less implicit rule that you have to internalize before understanding OOP. Other languages choose syntactic sugar over semantic simplicity, python isn’t other languages.
Answer 55948fb476b8fea65a0006bd
Thank you, this is very helpful. I’m still going to have to do some research to really grasp that, but this is a great start.
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency