Results 1 to 3 of 3

Thread: Anemic Domain Model and Service facade

  1. #1
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default Anemic Domain Model and Service facade

    Martin Fowler makes a very good point in his blog entry http://martinfowler.com/bliki/AnemicDomainModel.html about Anemic Domain Models: i.e. you should try to put all your business logic on you domain model objects.

    But what about business rules that are hard to check in the domain model? A typical example would be: "the userId of my User domain object should be globally unique". Since the User object is not aware of the database, nor of all other existing User objects, it can't really do this check.

    So this leads us to the question: is it ok for such a check to be done by a service object? Or should you refactor your domain model so that there is an object that can perform the check (e.g. a UserManager domain object that keeps track of all existing users)?

    Erwin

  2. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    My experience so far:
    don`t attach to much value to those remarks. If you want to do it good, you get more questions than answers. I haven`t found good solutions for a lot of domain-related problems.. everybody has (good) comments.. but nobody has solutions..

  3. #3
    Join Date
    Aug 2004
    Location
    Germany, Magdeburg
    Posts
    279

    Default

    But what about business rules that are hard to check in the domain model? A typical example would be: "the userId of my User domain object should be globally unique". Since the User object is not aware of the database, nor of all other existing User objects, it can't really do this check.
    In terms of a single user object the unique userId constraint is a constraint of the environment (only needed on creation time which is outside of the scope of the user type). So this is nothing to put into a user object.

Similar Threads

  1. Replies: 2
    Last Post: Oct 10th, 2005, 05:12 PM
  2. Shared domain model
    By ciaran in forum Data
    Replies: 18
    Last Post: Jun 7th, 2005, 09:53 AM
  3. Content Provider vs View Model
    By Martin Kersten in forum Swing
    Replies: 21
    Last Post: Mar 10th, 2005, 02:25 PM
  4. Domain model objects in session
    By jaypee in forum Architecture
    Replies: 3
    Last Post: Feb 10th, 2005, 02:16 PM
  5. EJB service layer non-OO / Anemic Domain Model
    By Aro in forum Architecture
    Replies: 0
    Last Post: Jan 15th, 2005, 07:10 AM

Posting Permissions

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