Dofactory.com
Dofactory.com
 Back to list
Views:   10.5K
Replies:  1
Archived

Adding Validation rules to the View in MVP

Hi, I am working on a MVP windows forms application and I would like to know if it would be right to put data validation in the view and in the model ? The example in the Patterns In Action only uses the Model for validation.

Thanks in advance.
Heleno Sales Mesquita, Oct 10, 2013
Reply 1
In general you always want to reduce code duplication as much as possible. 

Having said this, Validation is an area where this is almost impossible. The reason is that to get the best user experience requires that validation takes place in the UI (Presentation layer) in addition to the Business Object and Data Access layers.

In Web Apps there may be up to three places where data validation takes place (UI, Business Objects, and Data Access). A large chunk of the validation code is not reusable because of the difference languages involved, i.e. JavaScript vs .NET.

In a Windows app it is usually easier to share Validation code because it is all written in .NET.
So, the short answer is, yes, you can add Validation in the View in addition to the Model, but see if there is a way to share (i.e. refactor) the validation rules. 

Hope this helps. 


Jack Poorte, Oct 11, 2013
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.