Open StevenCostiou opened 4 years ago
Can you elaborate a bit more?
Each time we add a debugging tool, there is a class with a singleton that holds objects. For example, the halt cache uses a registry of halts, the debugger selector keeps instances of DebugSession, the object-centric debugger keeps instances of object-centric breakpoints, etc.
Basically all the (debugging) tools need to keep instances of things somewhere and control them from there.
We are constantly adding singletons, with different namings (defaultInstance, default, singleton, etc.), then testing them (globally the same way).
Why not having a "Singleton service" that proposes an interface for "Singleton clients" that would be able to register their objects there?
Yes, one tiny step: There was the proposal to add a Stateful trait for Singletons.
I understood @StevenCostiou 's point as to avoid singletons, not making them just easier to use. Singletons are in general not a good solution as they prevent testing, isolating changes...
Every new debugging tool seems to need a dedicated registry to hold its model instances. This leads to writing a singleton each time, and we see many tools implementing its own singeton in class side. Exemple: object-centric, halt cache, debugger selector, etc.
Could we think of another way? a better design?