An explanation of the Singleton design pattern and its purpose.
Great wikipedia entry:
http://en.wikipedia.org/wik...
And this one which I now think is inappropriate, but which I mentioned in the...
An explanation of the Singleton design pattern and its purpose.
Like to rate videos and let people know what you think?
Automatically share your ratings, favorites, and more on Facebook, Twitter, and Google Reader with YouTube Autoshare.
Autoshare makes certain YouTube activities public on the services you choose. Select only the services you are comfortable with - like Facebook, Twitter, or Google Reader - to let your friends know what you like on YouTube. You can turn Autoshare off at any time.
Like to share videos with friends?
Automatically share your ratings, favorites, and more on Facebook, Twitter, and Google Reader with YouTube Autoshare.
Autoshare makes certain YouTube activities public on the services you choose. Select only the services you are comfortable with - like Facebook, Twitter, or Google Reader - to let your friends know what you like on YouTube. You can turn Autoshare off at any time.
This video has been removed from your Favorites. (Undo)
Like to Favorite videos and let people know what you think?
Automatically share your ratings, favorites, and more on Facebook, Twitter, and Google Reader with YouTube Autoshare.
Autoshare makes certain YouTube activities public on the services you choose. Select only the services you are comfortable with - like Facebook, Twitter, or Google Reader - to let your friends know what you like on YouTube. You can turn Autoshare off at any time.
Singleton is the most well known anti pattern in OO. Please dont encourage it. Plus the example of db pools is shit, what happens when you want to employ diffent strategys in different environements, or mock the behaviour?
Yes, I indeed didn't mention that. However, this is an introduction for those who haven't yet been introduced to design patterns, so I'm keeping it simple. The wikipedia entry I refer to has a wide range of solutions for all kinds of languages, including a few multi-thread safe ones for java. I hope you find what you need there.
If you implement a singleton in Java please dont do the assignment of your singleton variable in the constructor. This is an unneccessary waste of resources (check for null every time you want to get your singleton). Do it at its declaration. This also prevents you from synchronizing access to the singleton to make it threadsafe.
Autoshare makes certain YouTube activities public on the services you choose. Select only the services you are comfortable with - like Facebook, Twitter, or Google Reader - to let your friends know what you like on YouTube. You can turn Autoshare off at any time.
Singleton == SHITE
how we can assure that this class will not instantiate by another object?
NOTICE the "PRIVATE Constructor" he wrote of a "Singleton CLASS"
but not recommend this in the multithreading.