• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

subclassing singleton???

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is that possible??
any good reference site???
thanx
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's perfectly reasonable to subclass a Singleton. "Singleton" is just a pattern, not an actual class, so you are free to implement it how you wish. I am interested in whay you feel you need to subclass a Singleton, though. Can you give us any more information about what you are doing with this pattern?
 
Ranch Hand
Posts: 1874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Faiza ,singleton pattern is used when you want to have one class only , not more , not less. As , Frank said you can subclass it. You can get more information about this in " Gang Of FOur " book , i.e. " Design Patterns " by eric gamma etc.
Like Frank , I am also curious about the utility of this in your project. Can you please elaborate about your purpose , if it is ok for you.
 
faiza haris
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well , I was reading an article on singleton, and had this question as to why and when emerges need of subclassing a singleton. Plz can u give a case scenario.
As regards any project.......well i might be given a project and was checking whether to go in patterns or EJB, Servlets cuz i have rational rose, uml experience.
Someone help decide!!!
any article for subclassing singleton? wht are the drawbacks for that?
 
Rancher
Posts: 1449
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I worked on a project where I remember discussing with someone about them subclassing a singleton class that they had. Can't really remember the context, so that probably isn't too helpful.
I think the most interesting thing about subclassing a singleton is whether you want the derived class to be a singleton or not since singleton-ness (is that a word?) is not inherited. In the case where the derived class is not a singleton then the question of why composition wouldn't work comes up.
Still can't remember why they wanted to do that subclassing. Guess I'll give up.
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic