开发者

What are some good uses of the Singleton pattern? Is it ever acceptable? [duplicate]

This question already has answers h开发者_如何学Cere: Closed 11 years ago.

Possible Duplicate:

Singleton: How should it be used

I've read that singletons are bad. For instance, it makes the code hard to test. Are there any acceptable uses of singletons?


Sometimes you want one and only one connection to a database. Making your connector a singleton ensures that you will not spin up multiple connections.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜