Where to put routine to perform data validation and read from/write to database in MVC designed user interface ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mark_Joshua
Posted On:   Sunday, March 30, 2003 06:13 PM

Hi,

I write a stand alone app, because the user interface might required lots of changes in the future, I want to apply the MVC paradigm in the user interface design to improve maintainability.
Where should I put the routine to perform data validation and read/write database ?

Any advice would be greatly appreciated.

Setya

Re: Where to put routine to perform data validation and read from/write to database in MVC designed user interface ?

Posted By:   Steve_Long  
Posted On:   Wednesday, April 2, 2003 02:24 PM

If you are actually following the M-V-C model, you already know the answer.

M = model, or the busines logic and processing rules.
V = view, the user interface portion.
C = controller, the systems processing controlling the app.

Data validation has at least two levels.

The first level is usuall field level. When a user enters data, there should be some level of user input validation in the user interface. For example, when entering a five digit zip code, the UI would ensure the entry was all numeric and of length five. This is field level validation which is independent of any other fields entered. What the UI would NOT do in most cases is verify the zip code is an actual zip code and valid for a given address.

A second level of checking is ensuring data consistency and possibly data validation. Data consistency is often in the context of other data entered on a form or screen, such as ensuring a zip code is valid for a given address and ensuring a given address is an address recognized by the postal service. Such validation rules can be quite complex and are usually driven by business rules. These (business) rules are in the Model portion of the MVC approach.
About | Sitemap | Contact