3 ms·
Presumably, so they can stub out the singleton for testing. It makes sense, sometimes, like the way your global database is a singleton that you really don't wa
by jfengel 6y ago
Presumably, so they can stub out the singleton for testing. It makes sense, sometimes, like the way your global database is a singleton that you really don't want on every test.
But in a lot of cases it's overkill and makes everything harder. Following a rule to always do it is simple but using your judgement is better. The best code minimizes side effects and reduces stubs and fakes.