Name of the anti-pattern of keeping old obsolete code around

995 views Asked by At

Recently I took a look at some code I'd committed to our version control system at work, and I found a bunch of it had been replaced (that's OK) but the old version was still there, commented out.

I guess the guy felt a bit "insecure" about deleting it, and therefore left it there commented out. However, that's not necessary, as we are using version control. (The old version was wrong, so it's not like it's going to be needed in the future.)

These stackoverflow questions deal with the question of if leaving old code like that around is a good idea or not:

However, my question is: is there a term for this sort of thing, or an "anti-pattern name" i can quote when talking to my colleagues about it?

4

There are 4 answers

0
Andy Thomas On BEST ANSWER

"Litter."

This is a term I use personally. As far as I know, it is not a recognized pattern name. But then, I don't recognize any of the others listed here. "Litter" communicates the concept and its worth immediately to those who have not read of the cute, obscure names.

2
Isaac Truett On

I've seen it referred to as an "unforgivable sin" but there's no formal name that I am aware of.

It could also lead to Duplicated Code, Long Method, or Large Class Code Smells if you consider commented code to have a scent. (edit again) Actually, the more I think about, "Bad Comments" should itself be a code smell. Commented code without any sort of explanation certainly isn't a helpful "comment."

2
Chris Dickson On

Wikipedia records this anti-pattern under the name Boat Anchor. Though I can't say I ever came across that usage before I just googled for it.

1
Chin Huang On

The Anti Patterns book calls this the Lava Flow antipattern, in which old, unused code remains in the code base, whether it is commented out or not.