A lot of times I'm asked about software best practices, but sometimes it's easier to show a best practice by showing its opposite -- a "worst practice". With that, today I introduce you to a worst practice I call "The Pigpen Developer".
Keep all your old code
The Pigpen Developer doesn't delete any old code, he just comments it out. CVS and SVN aren't reliable for him -- he needs to keep his old code close at hand. He doesn't believe in YAGNI (you aren't going to need it), and in fact, believes the exact opposite -- you are going to need it, you just never know when, so you better keep it nearby.
While commenting-out old code is one approach, a Good Pigpen Developer also keeps dead code lying around without commenting it out. I understand the first part of how it happens. You change your code a little bit, and then a method you were using before isn't needed any more. A normal developer would realize this and just delete it, right? Nope. A Good Pigpen Developer says "Hmm, I can't delete it, and I'd normally comment it out ... but what the heck, it isn't being called any more, so why do I just leave it there? If it's not going to be called there's no harm in letting it age."
Copy and paste like a madman
Another characteristic of the Pigpen Developer is that he copies and pastes code as though he gets paid every time he presses the Paste keystroke on his keyboard.
A good Pigpen Developer does this within one project, but the Expert Pigpen Developer copies and pastes entire projects. For instance, this last week, when I was working with one of these experts, I found a collection of projects in CVS that looked like this:
Customer1Foo Customer2Foo Customer3Foo Customer4Foo Customer5Foo . . .
It turns out that not only are these projects named similarly, they're actually near-identical copies of each other. That's right -- the entire project has been copied over and over, with minor changes to a few of the methods here and there. The Expert Pigpen Developer doesn't create libraries (jar files in the Java world), he just copies the entire code base whenever a new customer comes along.
Oh, and by the way, instead of using something like, oh, I don't know, a database, the projects get their runtime information from properties files that -- you guessed it -- have been copied and pasted. But not just copied and pasted, this expert also added a few parameters here, and deleted a few there, so some of the properties files have different properties than other projects, even though 98% of the code is identical.
(Note: A real software best practice here is to refactor your code so you don't repeat yourself. Don't be a Pigpen.)
Give your variables meaningless names
Here's another one of my favorites: give your variables meaningless names. A lot of Pigpen Developers define variables like
Properties p, or
Iterator i, but I'm talking about really meaningless names, things like this:
That's right, create a variable named
directoryName that implies that you're working with one directory, but define it as a list. So then, later, when another developer comes in to work with your code and sees something like this:
directoryName = getDirectory();
he'll think that you're really just returning one directory, but you (the Pigpen Developer) will know better. You've magically hidden a
List in your code and it will take the new guy quite some time to figure out what you've done.
Personally, I'm a believer in documenting my classes. Before each class I like to write the intent of the class, i.e., why I created it.
A Pigpen developer also believes in documenting his classes. At the top of every class you'll find his documentation, and it looks almost exactly like this:
/** * Created by IntelliJ IDEA. * User: pigpen * Date: Jan 18, 2006 * Time: 5:57:21 PM * To change this template use Options | File Templates. */
Unfortunately, based on a recent experience, I could go on for quite a while, but I'm going to stop myself here. I'm sure that other people have written about this syndrome before, but hopefully one day it can be cured.
Sorry, I thought I was done here, but I have to add a little more. It turns out that an Expert Pigpen Developer also does these things:
- Catches exceptions and then does nothing with them in the
- Leaves stuff like this in his code:
- Has database table fields not being used.
- Has database tables not being used.
- Has databases not being used.
- Answers "no" when he's asked if you can delete code and databases that have been dead for over a year.
Okay, I'll stop, I promise. Heck, I can't even take it any more.
Pigpen was a very cute character in the Peanuts cartoon series, but please, whatever you do, don't be a Pigpen Developer.