His argument is that entity objects should be more than mere data carriers.
Instead of putting some entity logic in the DAO layer and some more logic into the business layer, he argues that all the logic for an entity should be in that entity.
This certainly has some merits. Example:
public class Parent {
@Lazy
private List<Children> children;
}
In your code, you fetch a parent from the DB. Some while later, you decide to do something with the children. In the DAO world, the DAO framework must somehow inject a hidden field somewhere which allows getChildren()
to fetch the children of the parent from the DB.
If that field was part of Parent
, it would be really obvious how this works.
The same goes for business logic: If you change something in your entity, you have to look up all places where it's being used as part of the business logic and make sure that the change doesn't break anything. This would be more simple if all business logic would be in the entity.
Unfortunately, this won't happen with OO languages. The main problem is that you'd have too much code in each entity and for some code, it wouldn't be clear at all in which entity it would belong. Imagine some business logic which reads data from an input entity and writes that to an output entity. In which entity does such code belong? The input or the output?
OO simply doesn't allow to chop such problems into digestible pieces.