开发者

should singletons be avoided [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

evil singletons

Should I avoid using the singleton pattern?

Edit: Okay I wasn't expecting to get closed down.

I guess I should clarif开发者_JAVA技巧y a bit, I have been using singletons for:

1)storing a connection string to a database, or the role of the current user.

2) time consuming data to retrieve from a remote data server - it has a very slow connection.


The singleton pattern is not evil in itself, but if you overuse it, you will notice that it's not a solution for everything.

Like any pattern it has its use, but you should only use it when you need it, not everywhere that you possibly can.


You should if you agree with Google.

Nowadays I think Singleton would be the pattern most likely to be expunged from the Gang of Four book.

A fan? Really?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜