I am developing my first DDD application and trying to follow some basic rules I've studied in these last few months.
I've implemented the repository pattern with Nhibernate.
I thought I could have "moved" my entities from the controller to the view, but soon I've realized it's almost impossible.
Most people seem to prefer to define a viewmodel specific for each view.
I don't particularly fancy the idea to redefine the fields I've already create for my entities but it seems that this is the only way.
Now I am facing the situation where I want to attach some validation rules.
I thought I could have attached the validation rules (with DataAnnotations) to the entities but it can't work if I am using a viewmodel.
Here are the questions:
- Shouldn't the validation be part of the domain model?
- Isn't it time consuming to create the model and then spend time to remap the same fields (properties) on the viewmodel?
- Isn't this an anemic model, if it doesn't have, at least, validation rules? I am starting to wonder if DDD is really suitable for small/medium size application.
I appreciate any help/suggestion.