WHY IS DAO is implemented through an inteface :
Here are some short facts i was able to have together :
When i first saw the DAO layer in my project , i was like what man why should in make in entry in DAO interface for accessing the database.
And i thought : what the hell, just make an entry and let it be.
Today i got some time to research and see why should i really want it.
The points which i was able to gather is
1) It' s easy to create test. You can create new implementation for test case and use them
2) You can check for authorization before giving access to DAO LAYER.
3) It affects the Junit test case to run faster.
5) Its like separating your logic from the service layer and its easy for understanding for new developer.
6) You can use polymorphism to store the implementation detail in the parent object and be the king here.
7) The basic use of interface to define a contract is well used in DAO pattern. Just define a interface and be the king of jungle.
8) You can use generics in DAO layer to become the the king of the kings of the jungle
9) The DAO pattern allows clean separation of concerns.
10) for using the names queries always set the parameters in DAO implementation and shoot it.
That's all i was able to gather. Lets see if i get more i will let you know.
But in the end don't use the DAO pattern if your application is not that complex. Just do simple things instead.
As said : If you have a doubt in mind, always go simply.
Here are some short facts i was able to have together :
When i first saw the DAO layer in my project , i was like what man why should in make in entry in DAO interface for accessing the database.
And i thought : what the hell, just make an entry and let it be.
Today i got some time to research and see why should i really want it.
The points which i was able to gather is
1) It' s easy to create test. You can create new implementation for test case and use them
2) You can check for authorization before giving access to DAO LAYER.
3) It affects the Junit test case to run faster.
5) Its like separating your logic from the service layer and its easy for understanding for new developer.
6) You can use polymorphism to store the implementation detail in the parent object and be the king here.
7) The basic use of interface to define a contract is well used in DAO pattern. Just define a interface and be the king of jungle.
8) You can use generics in DAO layer to become the the king of the kings of the jungle
9) The DAO pattern allows clean separation of concerns.
10) for using the names queries always set the parameters in DAO implementation and shoot it.
That's all i was able to gather. Lets see if i get more i will let you know.
But in the end don't use the DAO pattern if your application is not that complex. Just do simple things instead.
As said : If you have a doubt in mind, always go simply.