4 ms·
I often keep commented out wrong code with an explanation of what is wrong with it in the comment. But most of the code I've written is experimental, often inv
by rapjr9 4y ago
I often keep commented out wrong code with an explanation of what is wrong with it in the comment. But most of the code I've written is experimental, often involving reverse engineering black box systems so they can be used in unconventional ways for research purposes. So that commented code is a series of clues into the hidden state of the black box and thus are important for gaining further understanding. Once I've figured out the puzzle then I decide whether it's important to keep those comments. If the code is passed on to someone else I'll often delete the comments, though I may copy them to a wiki for my own reference. If I'm the only one working on it I like to keep the comments unless they start making the code unwieldy and difficult to work with. I do replace the commented out code with a detailed description of my understanding of how things work, often quite extensive comments. I've had to work with too much code written by other people that is impenetrable because they didn't describe the codes purpose which makes making changes difficult. Keeping code "clean looking" is ridiculous in my opinion when the goal should be keeping the code maintainable.