File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is it ok to make a DAO class as Singleton

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume that we have methods such as insert , update , select and delete inside my DAO class . So please tell me if i make this DAO class as Singleton .

In my opinion this saves a ot of memory .please guide
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, no. Since Singletons are EVIL! ;)

Actually, using the DAOFactory-pattern is better. It allows you to control your DAO-objects in a way that makes it easy to switch the underlying DS and/or use a persistence framework.

Example on how to do: http://www.ibm.com/developerworks/library/j-dao/

Addition: Also, it makes testing and mocking a lot easier.
 
Arnold Reuser
Ranch Hand
Posts: 196
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my opinion this saves a ot of memory .please guide


If your using an EJB centric architecture use stateless sesion beans for this purpose.
Stateless session beans are pooled and therefore memory consumption is managed by the container.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic