1

Writing unit tests for singletons...

I would just want to refactor it so it’d be easier to unit test, but need to write unit tests in order to be allowed to refactor. Geez...

Comments
  • 0
    You mean by management? I don't believe you'll be allowed to refactor ever
  • 1
    Singletons are Evil(TM). They literally weld your code to a specific implementation and not some promise of a service (e.g. Dependency Injection) if you're doing OO based stuff. Suggestion #1 - if this thing that's using the Singleton is only built/used in a handful of locations, put an interface on the nasty Singleton, DI it via constructor injection & go about your merry way refactoring (that's what I've done in the past).
  • 0
    @alexbrooklyn nah, just management doesn’t really care as long as things work. It’s more about a refactor PR not even going to be looked at unless unit tests can prove that there are no breaking changes
Add Comment