About unread field or unused method

这几天被要求该用findbug找出来的问题,其实全部都是warnings,各种warning,用过findbug的童鞋应该知道的。

关于unused field或者unused method、import,编译器会在编译class的时候把它们优化掉,是加上它们不会对实际的程序产生什么影响。所以该不该都无所谓了。自己没法定论,然后去搜答案,果然有一篇不错的帖子说明了这个问题: Any reason to clean up unused imports in Java, other than reducing clutter?

引用

As always unused code will distract you and other people while reading the code and leaving something in your active code because of maybe I need it later is mostly seen as bad practice.


红字的部分化解了我的忧虑,其实往往觉得以后会用到,结果经常是不会再用到,等到用到时早已经有另外的办法了。

你可能感兴趣的:(UP)