commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: [BeanUtils] Error-checking BeanUtils.copyProperties() using Levensthein distance
Date Tue, 21 Nov 2006 23:35:54 GMT
On 11/21/06, Olivier Pernet <o.pernet@gmail.com> wrote:
> Hello,

Hi Olivier

> I'm considering using BeanUtils.copyProperties() to transfer data to
> and from DTOs, in a Web application. But I'm afraid that this would be
> quite error-prone, as misspelled property names would be ignored.
> So, I thought of overriding the copyProperties() method by computing
> the Levenshtein distance (implemented in Commons Lang) between
> property names, and logging warnings when this goes below some
> appropriate threshold. But that would obviously be much slower, and
> would be used for testing only, probably.
> What do you think of the idea ? Would you consider adding it to the
> BeanUtils class ?

Sounds like your planning to log warning messages along the lines:
   "Couldn't find property named 'foobar' perhaps you meant 'foobaa'?"

Personally I think this is overly complex and doesn't give that much
benefit over just logging a message  "Couldn't find property named
'foobar'". It could even have a misleading effect with properties that
have genuinely similar names.

Not quite sure what copyProperties currently does, but I'd be happy to
consider improving the logging messages - but I wouldn't want to
either a) add a dependency on Commons Lang for this (as both are
widely used libraries and could present users with version issues) or
b) burden beanutils with the maintenace of additional Levenshtein code
for what I see as minimal benefit.

> How do you cope with that in your applications ? I was quite surprised
> by not finding anything about that on Google - there must be quite a
> lot of bugs created this way.

I guess its probably a common mistake, but I'm sure people resolve it
quickly during testing when they see their target bean properties
missing.

Apologies for the negative response, but thanks for taking an interest
in contributing :-)

Niall

> Olivier Pernet

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message