Posted by Neil Crosby on December 12, 2005 11:03 PM
All good programmers know that copying and pasting big chunks of code from one place to another instead of refactoring out into a nice reusable method is A Bad Thing. It means that any bugs which were in the original bit of code gets duplicated to the place it’s copied to. It means that when we come to modify the original piece of code, we have to modify all the duplicates too. It isn’t a pretty sight.
Still, most of us are surely guilty of doing it from time to time, and that’s where PMD comes in to help by trying to reduce smelliness in your code. I’ve only being using PMD for a single day, but its “Copy/Paste Detector” has already helped me find several big chunks of code within the web-application that I’m maintaining which have clearly been copy and pasted in haste at some previous time. Later I’m hoping to get to grips with the other features of PMD - checking for dead code, overcomplicated expressions and possible possible bugs. Should be fun!
If you really enjoyed what you just read, why not buy yourself something from Amazon? You get something nice for yourself, and I get a little bit of commission to pay for servers and the like. Everyone's a winner!