Most common examples of misuse of singleton class

后端 未结 11 998
伪装坚强ぢ
伪装坚强ぢ 2020-12-16 00:19

When should you NOT use a singleton class although it might be very tempting to do so? It would be very nice if we had a list of most common instances of \'singletonitis\' t

11条回答
  •  我在风中等你
    2020-12-16 00:58

    In the case of a connection (for instance), it makes sense that you wouldn't want to make the connection itself a singleton, you might need four connections, or you may need to destroy and recreate the connection a number of times.

    But why wouldn't you access all of your connections through a single interface (i.e. connection manager)?

提交回复
热议问题