Announcement Announcement Module
No announcement yet.
JPetStore Design Question Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JPetStore Design Question

    Hi Springers,

    I have recently inherited a Spring project that is pretty much modeled after the JPetStore but on a much grander scale. Upon reviewing the code, I quickly noticed an interface to the whole data-access layer. This is a very heavy interface/class combo which has methods delegating to all the DAOs objects. My knee-jerk reaction is that it smells of the god object anti-pattern. Upon further research, I found that the JPetStore has a similar design (the PetStoreFacade), adding to the credibility (byway of reputation/respect to the good folks at Spring Source) of this design decision. So now my plans to refactor this interface/impl out are on hold until I can make a better informed decision. Please enlighten me on the merits of this design.


    Last edited by mayonesa; Nov 12th, 2008, 07:13 PM. Reason: better wording

  • #2
    Interface/class combo is some kind of design for the future, and of course not in all project you gain benefit from this. For example if you have the only one implementation the interface is not needed.

    BUT interfaces simplifies testing (mocking), of course we can mock classes, and second makes you to think about interface for your class which may cause better design.

    You also write about method delegation, from one point of view thanks to that you have clearly divided layers (business logic use services which use dao-s), on the other hand you have many service methods that looks like
     return someDao.someMethod
    All this doubts is OK, and if pattern doesn't suit to your code, do NOT use it. I don't know if I answer you, but also you didn't state any question.


    • #3
      the question is...


      Thanx for replying. My question is if it's a bad idea to have *one* interface/class combo for a whole data access layer composed of a bunch of dao's. Please look at the attached jpeg for clarification.

      Thanx again.


      • #4

        nevermind, i talked to one of the spring source staff members during springOne and he told me it's the facade design pattern.