A comment by SaltySeaDog over on my post Easier Property Validation with dynamic in C# 4* got me thinking.

You have some special use case that requires you to reinvent that wheel?

There are several wheels around - http://fluentvalidation.codeplex.com/ just to name one… or are you just prototyping for it’s own sake?

To tell the truth, I do think that someone needs to reform validation, not just within the .NET community, but for development in general.

Most validation frameworks (including every one of the dozens of frameworks I’ve downloaded and tried out) have an unhealthy obsession with data integrity at the expense of the user experience.

To a one, the frameworks wield a binary hammer - everything is either valid or invalid, and nothing invalid may pass, not under any circumstances at all.

Here’s a real world example I heard about just this past weekend: An ecommerce site that requires you to create a customer account before you can purchase. One of the mandatory fields on the customer account is a phone number - and that number must be formatted in the US style: (###) ### ####.

Unfortunately, New Zealand phone numbers aren’t written that way - we have area codes like 03, 09, 021, 029 and 0274, with phone numbers that are six, seven or eight digits long. Oddball? Certainly - but certainly valid as well.

Life isn’t binary - and validation shouldn’t be binary either.

We developers do actually know this - just look at our compilers.

Long past are the days were a compiler would just stop with a cryptic message at the first hint of trouble. Modern compilers are extremely good at error recovery, giving us not just one but a whole set of errors to fix up. Even better, our compilers give us warnings and hints as well, providing us with useful guidance that steers us away from poor practices and helps us write cleaner code.

If we value this kind of guidance so much that we build it into our own tools, why should we treat our users with any less respect?

Comments

blog comments powered by Disqus
Next Post
When Live Mesh fails  19 Nov 2011
Prior Post
Code Analysis failure  11 Nov 2011
Related Posts
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Method Archetypes  11 Sep 2022
A bash puzzle, solved  02 Jul 2022
A bash puzzle  25 Jun 2022
Improve your troubleshooting by aggregating errors  11 Jun 2022
Improve your troubleshooting by wrapping errors  28 May 2022
Keep your promises  14 May 2022
Archives
November 2011
2011