3 ms·
They aren't global, they're local to the source file, which represents a singleton class, so it's not really dangerous. You could think of them as static variab
by CGamesPlay 11y ago
They aren't global, they're local to the source file, which represents a singleton class, so it's not really dangerous. You could think of them as static variables in a singleton class.
- cballard 11y ago> You could think of them as static variables in a singleton class. So... global variables?
- ridiculous_fish 11y agoI'm not sure what justifies using a Singleton here - what if I want more than one Calculator in my app? I also noticed that we have a Store (which I interpret to mean model-layer) handling key events, e.g. "processBackKeyPressed()". Is that common too? From my outsider's perspective, this looks like a layering violation.
- CGamesPlay 11y agoI didn't write this so I am not in a good place to argue in favor or against any pattern, but the obvious answer here would be the needs of the application justify a Singleton. The app doesn't support more than one Calculator, adding additional object management for a feature that isn't necessary is strictly wasted effort. I don't think it's a "key event" in the sense you're imagining. The store is a black box around a calculator device with emulated physical buttons, so "back key pressed" is one of the store's fundamental actions. I might be wrong about this.