29 Nov 2004

Anemic Domain Model

I often read blogs pointing to the Martin Fowlers'Anemic Domain Model.
Personnaly, I've gone through 3 steps:
  1. layer mixing (where presentation/domain/database etc...) is mixed.
  2. then "overlayering" creating unecessary layers just to split things(concerns) but ending coping values from one object/layer to an other without doing anything more and having multiple objects with no behavior.
  3. refactoring this "overlayering" model to a minimum subset of classes and hading behavior.
The ideal thing (in my humble opinion) would be to use domain model (with behavior not only get/set) even in the view part of the MVC if there are no futher actions to take between view and domain. And concentrate every domain classes representing simple entities (Address, DrivingLicense ...) in one/few packages.
The problem with this approach is to prevent other people (just as myself 4 years ago) to put things in the domain objects where they do not belong.

No comments: