On 11/22/06, Niall Pemberton <[EMAIL PROTECTED]> wrote:
On 11/21/06, Olivier Pernet <[EMAIL PROTECTED]> 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'?"

Yes, that was the idea.

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.

Well, very similar property names are inherently error-prone anyway, so
I guess I'd be happy about that kind of false positives.

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 maintenance of additional Levenshtein code
for what I see as minimal benefit.

It doesn't log anything right now. Which may be better, as some users
probably make intensive use of it, and wouldn't want their logs to be
cluttered with this. And actually I wouldn't want it to log when a
property is not found : it's quite common to copy properties from a
source bean that has more properties than the destination bean, as
when you copy data from a domain object to a DTO.

> 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 :-)

It's fine, I just wanted to know whether people had a better idea than me.

Cheers
--
Olivier Pernet

We are the knights who say
echo '16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D4D465452snlbxq'|dc

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to