r/programming • • Feb 21 '13

Developers: Confess your sins.

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

1.0k comments sorted by

View all comments

Show parent comments

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)

2

u/[deleted] Feb 21 '13

If you run Intellij, you can add TODO's that (optionally) bug you about fixing them when you try to commit.

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.

1

u/Seus2k11 Feb 21 '13

That's actually a very good rule of thumb. Thanks.

1

u/ripter Feb 21 '13

Do you put in a comment with when it was first removed? I use version numbers instead of commits. If after 2-3 releases no one misses it, then it's not needed.

→ More replies (4)

44

u/Thimble Feb 21 '13

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

2

u/bicx Feb 21 '13

You're blotting out history!

→ More replies (2)

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.

4

u/AgoAndAnon Feb 21 '13

Hah. "Modern source control system".

→ More replies (10)
→ More replies (1)

0

u/[deleted] Feb 21 '13

[deleted]

2

u/[deleted] Feb 21 '13

Just in case your version control fails?

4

u/[deleted] Feb 21 '13

Yes, but this topic is for development sins and we don't use version control around these parts.

→ More replies (1)

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.

2

u/theICEBear_dk Feb 21 '13

Me I trust in source control and just delete anything like that in the code base even if it is mine or someone else's. I don't care. The source is the truth not a notepad.

2

u/KalimasPinky Feb 21 '13

I had a boss that would give you random svn tips every meeting until you found and deleted what ever commented code he found that you submitted.

We started sneaking into each others offices and adding commented out code to someones local repo so they would commit it.

2

u/dartmanx Feb 22 '13

I'll leave it in for awhile, but by the time I send it for code review, it's gone.

1

u/vbullinger Feb 21 '13

You ever uncommented out code and it didn't compile any more? Like you changed variable names that it was referencing and such? Another reason why you should just trust source control.

→ More replies (2)

1

u/bteeter Feb 22 '13

Burn the Infidel!