Do you find writing dead code useful?
Some says "If you have 2 logic to do some operation then instead of making other logic code commented or removing code make it dead code as it will not affect the operation."
Example:-
if(true){
// logic - 1
} else {
// logic - 2 // dead code
}
Is it true?
I usually do not write dead codes instead I just remove the second logic.
Best Answer
IMO, it is worse than pointless.
In addition to being a waste of time, it gives you (or the next guy) the illusion that you've got some code that will work if you change
true
tofalse
. It is only an illusion ... unless you test it.And if course, it is clutter that makes the code harder to read.