yeldiRium / st3k101

UNMAINTAINED.
2 stars 1 forks source link

Refactor singletons and global state out of backend #145

Open strangedev opened 5 years ago

strangedev commented 5 years ago

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.