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 -
- Keep the DAOInterface with all methods as is
- Implement a DAOImpl class which implements the DAOInterface but will not have any logic in any of the methods
- Implement Object specific DAOImpl classes which extend the DAOImpl and implement the DAOInterface and provide the actual DAO implementation for all object specific methods.
- Change the current DAOFactory class to provide instances of object specific DAOImpl based on some identifier passed from the business logic layer.
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.