why use daoFactory
Posted on 2006-04-18
In our java web application we are using this method for getting an instanse of a Dao Class by passing the name of the class as parameter string to this method and this method returns an object which we cast to spacific Dao Class.
public BaseDAO getDAO(String sDaoClass)
BaseDAO dao = null;
dao = (BaseDAO)Class.forName(sDaoClass).newInstance();
Now i want to know why this pattern is used to get the instanse of the class.
we can also get the object of a class by calling the constructor :
specificDaoClass referenceName = new specificDaoClass ();
then why we use this(getDAO(String)) to get instanse of classes.
what is the difference between these two approach,
is there any drawbacks ,limitations or benifits while using these approaches
i mean i m totally confused about these approaches
please give ur comments,share ur knowldge, not just google reference.
Thanks in Advance