I have read/write actions in my project something similar in this link
The suggested pattern in the answer was Singleton Pattern which is implemented with enum. But I have come across my code where we are following
- Interface containing read/write methods says ClassA
- Implementation of the interface methods ClassAImpl
-
Factory class contains the code as follows
public class ClassAFactory { public static ClassAFactory getInstance() throws Exception { return new ClassAImpl(); } }I have the following doubts
- Which is the apt design pattern to organize the code here in this scenario?
- What is the advantage of reusing the same instance again and again, rather than creating a new instance?
Someone please help me to know about this.
Aucun commentaire:
Enregistrer un commentaire