Kimbly has a post about Code Inertia talking about how the programmers in her shop write large amounts of code, with much copy and paste, to solve problems that could be solved more compactly. She's interested in trying to change this. To which I say:
What about the old reward and punishment routine? I'd say that it's very unlikely that the programmers will change their behavior on their own. The way they work now is fine by them, I'd go so far as to say that the way they work now is being rewarded. Producing a lot of code is probably regarded as a sign of being a code stud. Kimbly's comments imply that it might be. Are the people who write more lines looked up to, are stats maintained about how many lines each person wrote? If lines of code per programmer is tracked, even if no formal reward is associated with it, then I suggest stopping. Instead track something associated with the behavior you want to promote. One thing would be to track number of tests created and have some target for number of tests per lines of code, the more code written the more tests required. Unfortunately it's very difficult to directly measure the thing you want to promote, code reuse.
Another angle is to make it easier to do the right thing. If you use Java then IntelliJ IDEA or Eclipse with their refactoring support make it easier to reuse than to copy and paste. Instead of copying the code for a method from one subclass to another it's easier to automatically move the method to the superclass.
One suggestion, that of introducing XP, might work, but not if you continue to track lines of code per programmer. It's a way of adding a set of rewards and punishments that favour a particular style of development. I'd take a good look at the programming culture in your shop and see how it could be tweaked so that reuse becomes seen, and rewarded, as more important and valuable than lines of code.
Posted by Alex at November 20, 2003 08:38 AM