11 Generic DAOs and refactoring
-
If needed, retrieve the OOP Company project up to chapter 10 from DLO. It contains the classes as you left them at the end of chapter 10.
-
In this assignment you will refactor the DAOs so they use the generic
AbstractDAO. Copy or download this file and add it to your project. Both DBaccess and AbstractDAO are now generic classes that you can use everywhere. -
Make
DepartmentDAO,PersonDAOandEmployeeDAOsubclasses ofAbstractDAO. -
Rewrite the methods in the three specific DAOs so they use the
AbstractDAO. -
Test your DAOs by running the chapter 10 code again. You must remove the HR row from the
departmenttable in Workbench, otherwise you will get an error. You will see that you can add the employee Lodewijk to your database twice without problems.