Monday, January 21, 2008

Sign Your Work And Mine

I recently participated in a code review of a co-worker's new module. His work was great and mostly self contained but it did require a few minor updates to some existing source files that I had originally authored. Before he made his checkins I insisted that he add his name to the top of all files (new and modified) even if the changes were minor.

He was uncomfortable doing this. Some of the changes were quite small and he didn't think it warranted "taking credit" and didn't want others to view him as trying to take credit. I wanted him to though and it wasn't about credit as much as it was about team pride, team responsibility, and team ownership.

A few years ago I took the advice of a friend and read the The Pragmatic Programmer. It is a wonderful book that offers practical tips and guidance to programmers. It did more to shape my philosophy and approach toward programming than any other book I have read or class I have taken. I think it should be required reading for all programmers.

The last tip of the book says "Sign Your Work - Craftsman of an earlier age were proud to sign their work. You should be too". They explain "People should see your name on a piece of code and expect it to be solid, well written, tested, and documented."

Since then I always make sure that my code is "proudly signed" with full name and email address. I had one very bad experience with this however. At a former job I worked for a large company with lots of small projects and it was common to switch among them every few months. I knew many of the people at the company but it was impossible to know everyone.

One day I got a call from a co-worker and friend who recently joined a project that I had worked on a year earlier. He was tracking down a difficult bug which led him to some source code with my name on it. He asked me if I could spare some time to help him understand and debug it.

I walked across the building and into his office. He looked at me nervously and moved his monitor to show me the file he was looking at. I could see immediately that the code was a mess. It was not well formatted, comments didn't exist, variables with names like a1 and a2 were used and the logic was simply impossible to follow. There was no doubt that this code had numerous bugs. And right at the top of the file was my sole name and email address.

Using version control we were able to see that the file was completely changed by a contractor who had since been fired. All that was left of my original work was the header with my name in it. He didn't bother to remove my name or even add his.

I was furious. Had the reader not been a friend of mine, he probably would not have called me and would have forever associated my name with this crappy code.

It was clear that the project was not being well managed. They no longer performed code reviews and bad / buggy code was getting checked in. Moral was dropping and the developers no longer cared and no longer wanted to take credit. No one was signing their code! The project was in a complete tail spin and my name was one of the only ones that could be found in the source.

This caused me to take unprecedented action. For the first and only time in my career I went back to a former project and actually removed my name from all the source files! It was very disappointing and depressing.

So if I could amend the Pragmatic Programmer tip it would read as "Sign Your Work And Mine". If you edit my code, even in minor ways, do it right and sign it. The code is community work so if any of us get lazy it is all of our reputations that are at stake.

No comments: