344
ripbit
6y

Never delete code immediately. Always comment it out first.

Comments
  • 67
    Or use source control.
  • 2
    Like I always do :)
  • 31
    Don't commit out-commented code. Ever.
    Always use version control instead.
  • 9
    @filthyranter I sometimes commit commented code if its code to be, where the dependencies are not in place.

    Writing a stub, commenting it out and adding a todo line so it shows up in the todo list is a good way to quickly finish up once all else is done.
  • 7
    @Olverine @filthyranter Of course. I should've made it clear.

    I was carefully doing the Ctrl-Z Ctrl-Y surgery to get back the code I deleted prematurely. The dev saw me doing this a couple of times and decided to drop those words of wisdom that would guide me to this day.
  • 5
    Soft delete - staying in legacy until the end of times :D
  • 5
    Why oh why?

    Use local history of your IDE. Use version control. Never let commented code stick around.

    I consider this an anti-pattern.
  • 9
    This is exactly why our codebase is littered with commented out code.

    My colleagues adhere to your advice, but then always forget to delete it before committing...
  • 8
    On the plus side, technically, our codebase has lots of comments 😜
  • 3
    You fucked up rollback this file to orogin Head on git :P
  • 4
    Never delete C code. comment it out, but prefix it with a newline trigraph so that it looks like a comment but still executes.
  • 0
    No worries when using Android Studio since it has local history. Xcode sucks it doesn't have that feat πŸ˜‘
  • 1
    I learned that the hard way in my very initial days of programming.
  • 0
    When I'm about to rewrite some code, I always comment out the old code first, sometime i can reuse some of the old code.
  • 1
    Make sure you don't commit commented out code, one of our projects is full of commented out code and nobody dares to remove them (because they *might* be "important")
  • 0
    Words to live by.
  • 0
    @Voxera Of course, if it's an actual thing that will be used later on. But if it's just past used code, it has nothing to do in the current codebase, y'know
  • 1
    @filthyranter and thats where source controll like git is the way to go.

    Especially since commented code might not light up as removed in a diff, at least not at clear.

    So every “rule” has its exception :)
Add Comment