Reputation: 255
I am working on refactoring the data access layer for a project where I need to provide the business logic layer developers with a single interface for all DB interactions. Currently there is just one DAOImpl class implementing this interface but the class has bloated to 15000+ lines of code. Now I wish to move the methods from this class into multiple classes based on the type of object they handle. The approach I have thought of is -
I just wanted to validate my approach in this forum to see if I am doing things the right way or is there a better solution/pattern for this problem.
Upvotes: 1
Views: 2893
Reputation: 57381
I would suggest to have it in Facade like style. The main DAOImpl has references to all the sub DAOs delegating the calls to appropriate one.
UPD: to illustrate the approach
interface DAO {
void doSomethingUser();
void doSomethingProject();
}
class DAOImpl {
private UserDAOImpl;
private ProjectDAOImpl;
public void doSomethingUser() {
UserDAOImpl.doSomethingUser();
}
public void doSomethingProject() {
ProjectDAOImpl.doSomethingProject();
}
}
Upvotes: 1