“Singleton” factories, ok or bad?

后端 未结 6 728
伪装坚强ぢ
伪装坚强ぢ 2021-01-31 08:55

I\'ve a lot of (abstract) factories and they\'re usually implemented as singletons.

Usually for the convenience of not having to pass them through layers who really hav

6条回答
  •  梦毁少年i
    2021-01-31 09:12

    I would advise against it, because it makes it very hard to write decent unit tests for the code that calls these factories.

    Misko Hevery has a nice article about this on his blog.

提交回复
热议问题