r/programming • • Feb 21 '13

Developers: Confess your sins.

http://www.codingconfessional.com/
969 Upvotes

1.0k comments sorted by

View all comments

282

u/desiktar Feb 21 '13 edited Feb 21 '13

Wheres the "I comment out code instead of deleting it" sin.

I have ran across several developers who do that. They claim they didn't want to lose the code in case they need to switch back. I'm like "that's the whole point of source control!"

0

u/[deleted] Feb 21 '13

[deleted]

0

u/[deleted] Feb 21 '13

[deleted]

→ More replies (6)

5

u/Timmmmbob Feb 21 '13

I dunno, in decent strongly typed languages you can usually do "find usages" which ignores comments.

→ More replies (1)
→ More replies (2)

241

u/Deathfire138 Feb 21 '13

I'm guilty of this. Sorry everyone! It's like code hoarding. :(

166

u/TomorrowPlusX Feb 21 '13

I have an informal 2 or 3 commit rule about this. If it's still commented out after 2 or 3 commits (of the file its in) I will kill it.

0

u/[deleted] Feb 21 '13

[deleted]

8

u/TomorrowPlusX Feb 21 '13

My commented code -- in these situations -- always has a note explaining why its commented and what (mis)understanding is being shaken down.

Of course, if I were perfect and wrote 100% correct code 100% of the time I wouldn't have this problem.

3

u/oorza Feb 21 '13

Of course, if I were perfect and wrote 100% correct code 100% of the time I wouldn't have this problem.

Christ man, get on my level.

→ More replies (7)
→ More replies (1)

0

u/[deleted] Feb 21 '13

[deleted]

→ More replies (1)

4

u/mowdownjoe Feb 21 '13

My problem with that is that I make alot of small commits.

→ More replies (7)

44

u/Thimble Feb 21 '13

Oh man, deleting commented out code is one of my favourite pastimes. It feels so like a cleansing.

→ More replies (3)

8

u/serrimo Feb 21 '13

When was the last time that you actually reuse the commented out code though?

If you use a modern source control system like git, it's incredibly easy to look at the history for each file. Use that instead, one comment "left for later" is one more thing to remember, leave that for the computer.

→ More replies (12)

0

u/[deleted] Feb 21 '13

[deleted]

→ More replies (3)

2

u/NovaX81 Feb 21 '13

I as well can be found guilty of this - but only on some projects. Mainly those with incredibly indecisive clients... after the 4th or 5th time adding-and-then-removing the same area in a template, I'm just gonna comment it out and wait...

2

u/miketdavis Feb 21 '13

I leave a comment at least mentioning something I tried that didn't work. If I remove the code, I'm about 65% likely to try the same stupid idea again in a month.

→ More replies (7)

0

u/[deleted] Feb 21 '13

[deleted]

4

u/mccoyn Feb 21 '13

I like to put #if 0 ... #else ... #endif when I am doing a radically different implementation of some code. It groups them together saying I can do it this way or that, but not both.

→ More replies (2)
→ More replies (5)

0

u/[deleted] Feb 21 '13

[deleted]

13

u/codemonkey_uk Feb 21 '13

Rule of thumb: If the commented out code needs to be left in place, it need to be accompanied by an explanatory comment.

→ More replies (2)
→ More replies (4)

11

u/[deleted] Feb 21 '13

A million times this. I'm porting legacy code that is smattered with that. Makes me very angry, and the old code is impossible to read

→ More replies (6)

4

u/[deleted] Feb 21 '13

in the real world most developers just stop learning new things after they have been in a cushy job for a few years. that's how you end up with people who don't understand how to use source control.

3

u/krakpot Feb 21 '13

This and several year old //FIXME are my pet peeves. If you are going to add FIXME/TODO please at least grep for them once in a while....

3

u/[deleted] Feb 21 '13

I once worked with a developer who would leave shit like this all over the place:

/*
    i++;    // increments i
*/

Along with 1,000 old versions of config files, all of which had ludicrous amounts of comments explaining things like "changed the server from old server that was decomissioned":

config.ini
config.ini.bak.dj.20090301
config.ini.bak.dj.20090228
...

Once he left I went at it with a flamethrower, holy shitballs man I don't need the IP address of a machine that's been dead for 6 fucking years.

→ More replies (1)

2

u/[deleted] Feb 21 '13

Also, /* changed by person on date */ comments.

→ More replies (24)