DAO interface | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

DAO interface

Im making program that stores the information of clients and employees (which inherit from person) so my question is if i should make one DAO interface for client and other for employee or i should do it like this: public interface PersonDAO { public int insert(Person person) throws SQLException; } and then cast to client/employee whenever i want to do anything?

18th Jan 2019, 3:30 AM
Daniel
Daniel - avatar
3 Answers
+ 2
For readability, your interface should reflect how your tables are structured. If you have two tables (one table each), you should have two separate insert interfaces. If they are in one table, they can share an insert interface. I hope this helps!
18th Jan 2019, 5:38 PM
Janningā­
Janningā­ - avatar
+ 1
From the Java perspective not really, for the table performance it really depends on the access patterns. For most data which isn't too large, any performance difference should be negligible.
19th Jan 2019, 4:04 AM
Janningā­
Janningā­ - avatar
0
ok i have two tables so ill do two DAO interfaces, but is there a difference in performance between one or the other way?
18th Jan 2019, 7:06 PM
Daniel
Daniel - avatar