• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

DAO Pattern Question

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friends,

I wanted to ask,

why do we need java interfaces for DAOs? I mean instead of coming through CustomerDAOInterface, if I access CustomerDAO directly from sessionbean/service-layer, what's wrong with it? If I need to add a new method in future, I can still add it to CustomerDAO, if I need to change a method in CustomerDAO I can do that. If I need to use a different persistence package I still will be working with CustomerDAO class only in both the cases.

So why should I use interface for DAO classes?


regards
VC
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interfaces for all classes is just good OO for separation of concerns and High Cohesion, Low Coupling. It also allows something like Spring to inject these objects into your services instead of having to couple the DAO to you service.

Mark
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic