3 ms·
People are saying "shouldn't tests/code coverage fix this" or throwing around "static analysis" like it solves this issue. Yes, static analysis is useful for f
by abritinthebay 9y ago
People are saying "shouldn't tests/code coverage fix this" or throwing around "static analysis" like it solves this issue.
Yes, static analysis is useful for finding internally orphaned code (though a simple search and seeing if the references outside of tests are 1 is just as effective) but that's not all dead code. The article is just using that as a simple example.
If you have a feature that has non-orphaned methods your testing may cover it and your static analysis will say it's good but if it is never used then the code supporting it is effectively dead.
This code is dead weight to your code base. It's costing you time and effort to maintain or work around. Having the ability to track it down and remove it is important.
This is where other methods come in.
- cassowary 9y agoI think the other problem is that static analysis is a great tool for a new code base. But a new code base has no dead code. Or to put it another way, when you're designing a system, please think about the benefit static analysis will have in identifying dead code three years hence. But when you're trying to find dead code in that ten year old PHP code no amount of woulda's and coulda's will get rid of it. The intelligent person solves the problem they've got. The unintelligent person shoulda's coulda's and woulda's you into oblivion. (NB. I would probably choose a tool with a good type system, and I would try to write to its strengths, in any system I was designing today. But that still doesn't help me identify the dead code I've got.)