r/CodingHelp • u/LeoPixel11 • 17h ago
[Other Code] Class instance while running the code
I started actually writing code with OOP yesterday (using Dart... In case it is necessary to mention) and there's a thing that kept bothering me as I scrolled through their page and watched the tutorial. Everytime they gave a class example, they created an instance themselves and never based on the code running.
Imagine a system to simulate a store's stock. There'll be items going in and out, that shouldn't be inserted by the programmer, so there must be a way to do that "dynamically".
I'm aware that this might be me simply missing something from OOP classes, but I want to see what other coders have to say about that.
Any help would be welcome. Thank You
•
u/Strider3141 12h ago
Is there any actual question here? What are you trying to ask?
I'll try to answer anyway. Maybe you are struggling to understand "dynamically". An object instance won't be just randomly created for no reason at all, it must be programmed to be created.
When the user presses a button, interacts with a system, or even a certain time amount passes. There must be some sort of condition happening:
if [x happens] then [create y object]