A Generic Singleton Base Class
View Single Post
08-17-2008, 06:21 PM
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
I use a (probably bastardized) version of the registry pattern, which I understood to be an extension of the Singleton pattern, minus the addition of the getInstace() method in each class. So with the exception of a few variations in the pattern to incorporate factories, I make wide use of the constructor and wasn't thinking along the same line of what you're trying to present. I guess you can chock that up to the time of night.
Wait Just A Minute... I still don't get it. What's wrong with calling the constructor in a singleton? You're calling a method called 'construct' which just seems hackish to make something similarily named anyways, isn't it? Why not use the constructor already available to the class - regardless, it's still being stored in a static location, and you can still run an initial check to make sure it's an instance of Singleton first.
I may not understand, I'm not very educated in design patterns, despite trying to learn, but it just seems to me there's no reason why not to use the constructor.
The Following User Says Thank You to delayedinsanity For This Useful Post:
View Public Profile
Send a private message to delayedinsanity
Visit delayedinsanity's homepage!
Find More Posts by delayedinsanity