Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Repository vs DAO

  1. #11
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by aks View Post
    What about when there exists a user with the same user name you have provided? Domain Objects should no nothing about how they are persisted, so you ideally you don't inject the Repository to check to see if a user already exists.
    Well, the object at hand should not know, but that does not mean that the domain model as such is agnostic. If it is part of the usecase to prevent duplicates on user creation (which usually is the case), then that fact has to be represented in the domain model (usually in some repository class).

    So you should not just pass in an object in a generic method that invokes makePersistent() but use a dedicates service method that inserts a new user and performs the necessary checks to prevent duplicates.

    I would guess that ROO does support this, but I do not know the details (yet).

    Regards,
    Andreas

  2. #12
    Join Date
    Jul 2006
    Location
    Kolkata, India
    Posts
    217

    Default

    Quote Originally Posted by Andreas Senft View Post
    So you should not just pass in an object in a generic method that invokes makePersistent() but use a dedicates service method that inserts a new user and performs the necessary checks to prevent duplicates.
    I think this is what Eric Evans calls Domain Service in his DDD book. The domain service can in turn talk to repositories.

    Cheers.
    - Debasish

  3. #13
    Join Date
    Aug 2004
    Posts
    2,715

    Default

    Quote Originally Posted by debasishg View Post
    I think this is what Eric Evans calls Domain Service in his DDD book. The domain service can in turn talk to repositories.
    Yep. That was the background of my suggestion. And that is why I suspect that it should be achievable with ROO.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •