• 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

where can use single object

 
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know the sigleton design patter but i dont know where should i use it.
what are the applications of singleton design pattern?
as ia m developing online examination using jsp, servlets can i use this singleton deg pattern in my application???


 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally I'm trying to avoid using singletons in building applications. Unfortunately it isn't always easy, for example configuration is something required for most of applications and fits in singleton pattern perfectly.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Singleton is most useful when you need to control access to a particular resource. For example, in my test engine one class controls all loading of XML test script documents and tracks the usage of these DOMs. Obviously, having more than one instance of this class would be a big waste of memory and make debugging harder. Therefore the constructor is private and a static "factory" method handles initial creation of the single instance.
Bill
 
saikrishna cinux
Ranch Hand
Posts: 689
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok thanx but can i sue this concept for user login
so that the only one user can login with his PIN and no other can login by using the same PIN?
can i do this ?
 
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by saikrishna cinux:
ok thanx but can i sue this concept for user login
so that the only one user can login with his PIN and no other can login by using the same PIN?
can i do this ?



No. Singletone is not for that purpose.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Chetan is correct.

You might have a UserManager class using the Singleton pattern since you only need one UserManager for the entire application. UserManager could track all logins and be able to tell if a particular PIN was in use.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic