Sunday, September 12, 2010

Validation Overkill

"The price of reliability is the pursuit of the utmost simplicity. It is a price which the very rich find most hard to pay."
Sir Antony "Tony" Hoare, 1980

People keep inventing new ways of validation, and that's really good! The problem is when they want them all in the whole same form!

[This link] provides an example I have elaborated about what I have called "Validation Overkill."

I will list some overkill principles:
  • State validation constraints, before, while and after:
    before: by using a label, and description of the time of data and its formatting
    while: show errors while typing data, or when changing focus, with Javascript or AJAX
    after: it's normal that back-end rejects wrong data
  • Indicate validation errors. It's normally done by adding a red color to a data field
  • List a summary of errors with anchor links to data fields, normally at the top of the form.
  • Retell errors, just like the while part of validation constraints.
You are right! Of course these principles looks nice enough to take them into account, but there are some inconveniences:

Javascript problems: visibility, library size, duplication of validation code, excesive AJAX
  • Javascript code is visible
  • if libraries are big, they will take time to be downloaded
  • sometimes it's needed to validate twice: front-end and back-end
  • excessive ajax requests can kill bandwidth
User traffic and bandwidth: ajax
  • If your user base is big, it will be a load for your server
  • AJAX is a process running on back-end, not in the browser.
Processor power
  • You would like to squeeze the total capability of the machine, but
  • sometimes to pay for a CPU upgrade, or
  • to buy an extra CPU to use as replication could be a faster way to solve latency
And very important, amount of fields!!
  • because all these rules are present in every field of an input form,
  • and specially if those fields are required
But, as a friend of mine says: "That's what we are paid for!"

No comments:

Post a Comment