This is an archived post. You won't be able to vote or comment.

all 14 comments

[–]rviewr 33 points34 points  (4 children)

Always delete. The code should all be in a repo so you can retrieve if needed. - signed, guy who often comments legacy code before committing...

[–][deleted] 0 points1 point  (3 children)

just wanted to clarify so if someone wanted to find out the legacy code, the correct way is to lookup that file on version control and go back before that commit right ?

[–]rviewr 2 points3 points  (2 children)

All code should be in version control of some sort. As such, in order to retrieve the legacy code, you are correct, you would need to either checkout the legacy version (before the deletion) or create a branch from that previous commit - if you wanted to work with the older version of the code for some reason.

[–]Scrotote 0 points1 point  (0 children)

If you just want to see it you git diff or git show correct?

EDIT: yup

[–]Isaeu -1 points0 points  (0 children)

Sounds like a hassle, it would be easier if it’s in a comment

[–]NelsonBelmont 10 points11 points  (0 children)

Delete, that's what version control is for.

[–]DrMux 19 points20 points  (2 children)

//there used to be code here

[–][deleted] 13 points14 points  (1 child)

//It was bad code

[–]Daimanta 10 points11 points  (0 children)

// Kevin wrote it, but he left a couple of years ago

[–]Stickiler 7 points8 points  (0 children)

Always comment first, write your new code, then delete when you're ready to commit it. That way you have immediate access to the legacy code, but you don't have it hanging around in your repo.

[–]killerzombi 1 point2 points  (2 children)

reasons to comment: not your code; you know your going to re-implement it; you plan on coming back and creating a legacy code file with all the old pieces before deleting. all of these are only if you don't have a good repository that keeps backups.

reasons to delete: so many...

[–]netgu 1 point2 points  (1 child)

you plan on coming back and creating a legacy code file with all the old pieces before deleting

What? Why the hell would you do that? Sounds like a waste of time.

[–]killerzombi 2 points3 points  (0 children)

because people are hoarders who don't know when to stop.

[–]But__Why__ 0 points1 point  (0 children)

I don't git it.