Everybody has heard the phrase ‘Garbage In , Garbage Out’. The developer is the first line of defense against the garbage going in. Although a developer cannot safeguard against items like a misspelled name or inverting two numbers within a telephone number, there are many things he or she can do.
The general rule should always be ‘f you can perform a validation to ensure accuracy and not allow bad data into your application, then do so.’
Dates are much easier now than in the old days when you had to validate that a date was really a date and in the proper format, but there are still date validations you can do. If your application requires a birth date, you should always make certain the date entered is not a future date. There won’t be anybody born in 2062 that needs to be entered into your system today. If you also have an employment start date and end date, you should ensure that the start date is not greater than the end date (if the end date exists), and that the start date entered is not earlier than the employee’s birth date.
Phone numbers can be checked to ensure they are the proper number of digits and all numeric. Email addresses can be validated to ensure they are formatted properly. If it is extremely important to your application, you can make them enter it twice or email them a verification to be completely certain it’s been entered correctly.
If you have a field like state code or country code always use a drop down or validate the keyed entry against your master table.
If it is important to the organization using your application to use titles for their customers like Dr., Mr., Mrs., etc, and you are also capturing the gender, it might be wise to ensure gender for Mr. is always male. This could save you, your company, or your client from sending an invoice to Mr. Tiffany Tidwell.
You should keep in mind that depending on who is keying information into your system they may not even be looking at the screen while typing. If they are typing from a list or stack of forms, their eyes will be on that list or a stack of forms, not the screen. If you write the code to validate your data properly once you can stop erroneous data from entering your system hundreds or thousands of times.
(Source: Skynet Solutions)
By: DJ Burrup