Chapter 7. Validation
Make it idiot-proof, and someone will make a better idiot.
Unknown
Adding error-checking and -handling to a GUI application (desktop or web) is something that is usually an afterthought and a horribly tedious chore. Most programmers hate the task, but we have to do it: We can’t just pop up a dialog saying “O NOES!!”—much as we’d like to—if the user does anything wrong. And no matter how simple and elegant we make our applications, two forces are against us:
- In the Real World, services go down (server crashes, database issues, and so on).
- The world is full of, um, less sophisticated users.
Worse yet, even advanced UI frameworks have historically provided basically nothing as far as a standard validation framework. Like it or not, “has great error messages” hasn’t been considered a major selling point of an app. So, we were left cobbling together our own, usually as an afterthought.
Fortunately, both Flex and Rails are different than the norm in this respect: For both Flex and Rails, validation is an integral part of the framework. This is good, because doing something wrong is an integral part of how users will use our applications.