this post was submitted on 05 Aug 2024
19 points (95.2% liked)
Learn Programming
1625 readers
1 users here now
Posting Etiquette
-
Ask the main part of your question in the title. This should be concise but informative.
-
Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.
-
Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.
-
Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/
Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You are taking a short online class. The class has objectives.
The class itself is defined by what it is supposed to handle (students mastering X skills). But the class by itself is only a structure, a definition that can be used to standardize ehat this sourt of course will look like. Within that class are actual students producing work that is more or less in line with the class objectives. These are objects that belong to the class that contain work.
A class is the structured definition. So you could have a class “factory” that defines a factory as a large building that takes in raw materials and outputs a specific type of finished goods.
The automotive factory on Fifth would be an object in the Factory class. That factory itself would be populated with contents defined by how the factory was operating.
Likewise in Python, you can define a class Greeting that contains a single string. You can then define an object friendlyGreeting of type Greeting, and that object will automatically contain a single string, because that’s what objects of class Greeting have. You can then populate the string in friendlyGreeting with the characters “Hello World” and you have an instantiated object. You could then have another object inheriting Greeting named unfriendlyGreeting. It will also inherit the single string element. But if you never instantiate unfriendlyGreeting, it won’t be usable in your program, and will have no actual contents.
So to sum up, classes define the structure of objects you use in your program. Objects define specific “things” that you can make copies of and interact with in your program. When an object is actually used and is containing data to be used in a specific way in your program, it is instantiated (there is an actual instance of that object).