… unless your have a good reason for it!
Already a year ago I wrote my Validating Data series. And only a couple of weeks ago me and my colleague were investigating one of our solutions that had a performance issue and were faced with code that wasn’t quite SMART with respect to using VALIDATEs. If you’re not sure what I am referring to (re)read this post: Validating Data #4: Assignment and VALIDATE.
Rule-of-Thumb vs. Rule-of-Thumb
And there we were sitting. Me wondering how an intelligent developer could have done this. My colleague (not his code; not mine either) wondering what actually was wrong about it. As became clear we both were looking from a very different perspective at these lines of code where a number of fields were populated and validated at the same time.
My perspective based on the rule-of-thumb saying: Never use VALIDATE … unless you have a (very) good reason for it. Or, quoting Marq in my post, “… to avoid the validate statement when populating records …”.
My colleagues rule-of-thumb: always validate a field when assigning a value, because you’re never sure validation code is behind it.
I (still) think I could make my point and could clarify that his rule-of-thumb is definitely not a good enough reason to use VALIDATEs. So I would like to stress to you all again:
Never use VALIDATE …
… unless you have a good reason for it.
If you’re not sure what I mean or disagree. Read my Validating Data series and challenge me below.
… dimishing the number of VALIDATE statement in our code did help, but (unfortunately) wasn’t the main problem.
After you did read this post be sure to read the comments below as I wrote it because of the discussion. And of course, if you did not read my Validating Data series yet take your time for it.