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?
精彩评论