Reputation: 1682
I've been reading up on this anemic domain model issue, which Fowler describes on his website.
The way I understand it, he says domain model classes should contain the business logic connected to them because that's more OOP and has some other advantages.
Now my question: Let's say I use hibernate, in which case I annotate my entity classes with JPA or Hibernate annotations.
According to Fowler, these entity classes should then contain the business logic?
I am asking because according to Robert Martin (he says it in a couple of talks available on YouTube), you should never put your business logic in classes that contain third-party code of some type. Instead, the business logic and business rules should be separated and protected from technology-specific details.
Am I right in saying that they kind of contradict each other? Or am I just not getting it?
And again: According to Fowler, I should put by business logic into the entity classes (like User, Product etc.) that, in case I use a presistence framework, contain alll those technology-specific annotations?
I always thought that you should try to be as decouple as possible from third-party code, in order to protect your own code from unexpected changes.
Upvotes: 3
Views: 122