Question

Using C#/.Net, I have a page where the user can enter data and save these data by clicking a button.

To save data, the user needs to enter a valid date, this means a date which has a certain format.

The page contains amongst others two modules.

The ValidateDate-Event has the responsibility two check the format of the date-field. So it checks the format and displays a message if the date is not well formed.

The Save-Event has to save user entries. To successfully complete the task, a well formed date is needed. So I designed the module to check the date format. This has the advantage that the module can never crash and is not dependent of the Validation-module. But I realized that in fact I do the same thing twice, in two modules.

I am just curious, how do you handle this matter? What do you think is the best way to do it?

1) ValidateDate

Reponsibility: Check format of date field (, inform user)
Sub-Task: Check format of date field

2) Save

Reponsibility: Save data
Sub-Task: Check format of date field

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top