Home  /  Questions  /  Question



Oct 10, 2013


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.
 1 comment
 
Your site has a lot of useful information for myself. I visit regularly. Hope to have more quality items. [url=http://flipdiving.online]flip diving[/url] --- Flip Diving  1 day ago



0   0
1 day ago
It's easier to share Validation code in Windows app.
__________
192.168.1.1
 1 comment
 
Hello. I know to your page via google and very looking forward to communicate and exchange information with you. Let's make friends by visiting my page. flip diving --- Flip Diving  1 day ago

508   99.9
Oct 11, 2013
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.