8/4/15

why we make interfaces for Dao

DAO Implementation




Just out of curiosity if you are looking for the reason then u should know this comes under broad topic of Factory design pattern.

In this type of implementation we create an interface and list all the required functions.
This interface is then implemented by various classes (can have various type of implementations).
If tomorrow u want to change underline implementation then u can do it without disturbing the existing application code.
All you need to do is to create another implementation of this interface.

For example :-
I java application u have written DAO interface and then its implementation using MySQL database. Now later if you want to change the database(let's say it is Oracle for now), all you need to do is to create an implementation layer in Oracle. Application will be indifferent of this change.