<a href="mailto:pondyprem@yahoo.com" rel="nofollow">pondyprem@yahoo.com</a>
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
SCJP2<br />IBM Certified Solution Developer<br />MCSD
Those private members and attributes are still in your subclasses. Your subclasses just cannot access them directly.
how do you extend a Singleton, if a Singletons constructor is private?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Kyle Brown:
Yes, I agree they're not Singletons. One of the key things about singletons is that they can be extended (subclassed). Obviously you can't do that meaningfully with classes that only have static methods.
Kyle
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ilja Preuss:
Well - make the constructor protected?
Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Originally posted by Kyle Brown:
Yes, I agree they're not Singletons. One of the key things about singletons is that they can be extended (subclassed). Obviously you can't do that meaningfully with classes that only have static methods.
Kyle
Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
I'd probably change my original singleton class to be abstract and then make two subclasses to implement the two different ways of pooling, but that's beside the point
Originally posted by Ramesh Donnipadu:
What if your client application start instantiating both of your sub-classes? Won't it defeat the purpose of Singleton? Similarly what if your clients start instantiating the superSingleton class and SubSingleton class?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
The client isn't responsible for instantiating the singleton and wouldn't need to know about the subclasses. It's the abstract base class that would decide which actual implementation to use, for example depending on configuration.
Originally posted by Ramesh Donnipadu:
I feel there is a difference between the clients needing to know something versus the clients can not do something. The later helps the prevention of accidental or wilful misuse of your class.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|