4 ms·
I'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
by ridiculous_fish 11y ago
I'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.