Only an idiot would have parameter validation, and only an idiot would not have it
The great thing about parameter validation is that there are people who say that only idiots would have it, and other people who say that only idiots wouldn’t.
Back in the old days, Windows didn’t do parameter validation. If you called a function with an invalid window handle, your application crashed. If you called a function with an invalid pointer, your application crashed. If you called a function with an invalid bitmap handle, your application crashed.
There was a lot of crashing going on.
These crashes manifested themselves in the infamous Unrecoverable Application Error dialog, commonly known as the UAE message.
Windows 3.1 added parameter validation to all of the functions in
GDI. If an application passed an invalid window handle, then instead of crashing, it just got an error back.
This change was met with derision. “Oh, I’m so impressed. You finally got around to doing something you should have been doing all along. Not doing parameter validation was a totally idiotic decision.”
But nowadays, parameter validation is out of fashion again. If you detect an invalid parameter and return an error code, then all you’re doing is masking a latent bug in the application. It should crash and burn with a big red fat’n’ugly blinking exception.
In other words, we should go back to the way things were before we added parameter validation. (Well, except that the bit fat ugly exception wasn’t red and it didn’t blink.)
Who’s the idiot now?