Some classes are singletons to provide a single point of access to some functionality, for example the XApiPublisher. This makes it harder to test and is generally considered an antipattern.
Another hurdle to writing useful tests is the global state stored in the g variable.
Storing configuration and database connections in this variable is convenient, but requires the state to be set up every time before dependent code can be tested.
We should refactor the backend to remove all singletons and minimize the global state required for the application to function.
Some classes are singletons to provide a single point of access to some functionality, for example the
XApiPublisher
. This makes it harder to test and is generally considered an antipattern.Another hurdle to writing useful tests is the global state stored in the
g
variable. Storing configuration and database connections in this variable is convenient, but requires the state to be set up every time before dependent code can be tested.We should refactor the backend to remove all singletons and minimize the global state required for the application to function.