I would offer a caution here. Validation of data needs to consider the whole system.
No validation is an obvious problem. Bad data --> bad results. But redundant validation is also a problem for a few reasons. Redundant validation happens when data flows through a system and gets validated for correctness at multiple points. Not only is this vulnerable to inconsistent validation rules but also a potential performance drain. Suppose a piece of data gets inserted into the system, applied to a setter and validated before entry into a dictionary. Then later gets copied from that same dictionary with a getter and then applied to another setter, perhaps on another object - do we validate it again? The general rule of thumb is to validate as close to the source of input as possible so that the corrective responses are most appropriate / contextual with the way the data is input. So this is not a disagreement, but rather a caution. We just spent a phase a couple of months ago completely refactoring our data validation model to address these very sorts of problems, so it is an issue that is fresh on my mind. -----Original Message----- From: Daniel Wilson [mailto:[email protected]] Sent: Wednesday, February 24, 2010 10:29 AM To: [email protected] Subject: Re: Check for allowed values in setters? IMO, checking for legal values is absolutely the right idea. Daniel On Wed, Feb 24, 2010 at 3:56 AM, Johannes Koch < [email protected]> wrote: > Hi, > > when adding features to the current PDFBox code, I sometimes wonder whether > it would be a good thing to check for correct values in setters. E.g. the DL > in a stream dictionary must be a non-negative integer according to PDF > 32000-1:2008. In some dictionaries some entries only allow values from a > list of defined values. > > pro: PDFBox will create proper PDF > > contra: this may be restricted to one PDF version and needs to be updated > if the value definition changes from spec to spec > > -- > Johannes Koch > Fraunhofer Institute for Applied Information Technology FIT > Web Compliance Center > Schloss Birlinghoven, D-53757 Sankt Augustin, Germany > Phone: +49-2241-142628 Fax: +49-2241-142065 >
smime.p7s
Description: S/MIME cryptographic signature
