4 ms·
I only delete code I know I'm not going to use later. Refactoring, especially renaming files, WILL make it next to impossible to find "that one bit of code you
by mschuster91 13y ago
I only delete code I know I'm not going to use later.
Refactoring, especially renaming files, WILL make it next to impossible to find "that one bit of code you know that does the trick", because even with a rgrep or git blame it will not turn up.
As soon as the commit history is >50 commits, it's also not feasible any more to scroll through hundreds of pages of diffs.
Side note: find a way to easily store "intentionally dead" code in a file, in a way that it does not show up in the code, but can be searched at least on the commandline - easy way to get rich. Devs all over the world will love you.
(I'd imagine replacing a block of code e.g. with /* REMEMBERME /, git detecting this block (and inserting a / REMEMBER-ID 12345 */ instead), and git supporting a command like "git show-dead file.c" which shows all the dead code, too.)
- spuz 13y agoMaybe you are unaware of git pickaxe. See the -S option of git log: https://www.kernel.org/pub/software/scm/git/docs/git-log.html https://www.kernel.org/pub/software/scm/git/docs/git-log.htm...
- mschuster91 13y agoIndeed I was, yet still this forces me to remember a part of the string of the code I deleted... which may not be the case if the commit was a month or two (or more!) ago. I mostly remember just "ah, this was in class XYZ"... open it, quickly scan the file for the comment blocks and voila, there's my code.
- stinos 13y agoI only delete code I know I'm not going to use later. Refactoring, especially renaming files, WILL make it next to impossible to find ... It won't, if you use proper commit messages. Once you start doing that, you'll soon discover it will make everything much more discoverable. Apart from that, death to dead code! Having worked on a project where about 10 to 20% of the code was effectively dead (either simply unused, commented out, #ifdef'ed away of if( 0 )'d away) I can assure you I never ever want that again, mainly since the dead parts still turn up in every search/grep/find reference.
- JetSetWilly 13y agoThat's great, if you work by yourself and are very disciplined. In fact most of us work in very undisciplined teams - I could myself lucky when colleagues write a descriptive comment at all.
- jcromartie 13y agoFor things like this, I just remove the code and leave an explanatory comment indicating what's not there anymore and why, and what revision it was last seen in.