The DAO
pattern forms part of the core
J2EE pattern set.
The DAOFactory is supposed to create a new Dao() rather than the Dao implementing the Singleton pattern.
This feels right to me. However, it does result in lots of objects being created during the running of the J2EE application, probably with no instance variables. I doubt that this takes up many resources and that they are garbage collected easily after the business method has finished with the DAO.
However, you could save any instantiation by using the Singleton pattern for the Dao.
Are there good reasons why not to use the singleton pattern in this way?
One reason that occurs to me is that it would cause confusion when subclassing a Dao. I'd be thinking to myself, "What does the author of the superclass want me to do? Should I make my subclass as singleton too...".
Any others?