9

I have a friend which have a hoarding disorder when it comes to coding. Here are some of the things he does:

1: If he rewrites, remove, or in any other way refactor a function, then he keeps the old one in the file commented out.

2: If he deletes a class then he takes the code and paste it into a class that he have just for old code. AN ACTUAL CLASS! Not just some random text file somewhere. Even though it is commented out, he leaves it so that you can initiate his garbage.

3: In point 1, the code is not pasted on the end. It inside all the other actual code.

So if you try to help him with something, then you have to dig through a mountain of shit just to find some code.

Comments
  • 3
    I am guilty of similar things although not as bad as you describe. It feels so hard to remove functions, even though I know that they are on Github and I can restore them if needed be...
  • 1
    @prvInSpace @hasu why?
    All that comes to mind is because of insecurity. In case new code would be worse or wouldn't work and you forgot how to use git at the same time.
  • 0
    It’s not *necessarily* a bad practice. I do this when I want to try a diferent method of achieving an end, but want to refer to the existing work I’ve done (though usually instead of commenting out I’ll just duplicate the element as function_old() or file_old.php).

    Now, if it remains in once the tests are done and rolling out to Production, *then* we have a problem...
  • 2
    @nnee partially insecurity yes. I tend to keep old functions for reference of approaches I tried, or as a reminder on how to use things. I remove them once I'm really sure I don't need them anymore. Sometimes i like to keep them to compare different approaches.
    And no, i cannot just google them. Research code. So not many examples given.
    I ended up having a file with all of the ones i think of usefull for experimenting and testing.
  • 0
    I used to do this but the more I leaned design patterns and refactoring techniques the more confident I became with with new functions I was writing replacing old ones.

    Basically if you code modular enough, all your methods are so small it makes this kind of thing pointless.
Add Comment