views:

43

answers:

1

Is it a good practise to decouple input checking from a model and have it handled elsewhere, say by a controller? If so, how could this be done from an MVC or DDD standpoint?

+2  A: 

It is a good practice to perform UI validation.

E.g. if Your domain object expects date time, it is correct if UI part of application ensures it will receive from user correct string, will parse it to date time and pass it to domain object.

Bad example: UI part validates if bank account has enough money for transfer.

However - can't give any tips how to implement properly this kind of validation in framework You are using (I'm not working with java).

Just don't keep it in controller. That is not controllers responsibility.

Arnis L.
Thanks for the feedback Arnis. So any parsing or matching can be done directly in the UI. About the bank account example, that sounds like something that could be made into a `Service` (DDD). As for validation in an MVC context, the reply posted on this link is an interesting read.http://discuss.joelonsoftware.com/default.asp?design.4.354410.6
James P.
@James need for domain service quite often is a sign that there's a missing aggregate root in Your domain. Another interesting read about validation - http://www.lostechies.com/blogs/jimmy_bogard/archive/2009/02/15/validation-in-a-ddd-world.aspx
Arnis L.