Is removing unused functionality a bad thing?

允我心安 提交于 2019-12-11 01:08:17

问题


Is it possible for YAGNI to apply in the past tense? You created some functionality, it was used a little bit a while ago, but you aren't using it any more, and you don't want to maintain it, so you'd rather delete it.

Is getting rid of unused or rarely-used functionality neccessarily a bad thing?

Background:

  • I use source control, so if I need the functionality again, I can get it.
  • I'm the only user of my software (I'm a bioinformatician analyzing a data set).
  • One scenario where I came across this was that I was using inheritance, with a parent class, and two child classes. One was handling files generated by 454 sequencing (next-generation sequencing), and the other was handling files generated by Sanger sequencing (previous-generation sequencing). I was actively maintaining the latter, but not the former. Maybe my mistake was using inheritance rather than composition, but that's a slightly different story.

回答1:


Unused code is subject to 'code rot' - it's completely legitimate to remove it as a refactoring step.

Some additional discussion on C2's YAGNI and Deleting page.

That said, I find myself generally being conservative with culling dead code, but that's something that maybe I need to work on...




回答2:


Dead code is expensive in many ways.

The thing that bothers me the most is the friction and added labor it causes when refactoring.

Press the delete key. If you need it later, go to SCC and get it.




回答3:


Novice programmers are proud of the new features they've coded. Master programmer is content when he's able to remove a feature.




回答4:


All the reason why you should not write code that is not used apply also to why you should not keep around code that is not used. If you ain't gonna need it, don't keep it around. :-)




回答5:


Delete it. How about a new acronym, YGRKI - You're Gonna Regret Keeping It?



来源:https://stackoverflow.com/questions/2769851/is-removing-unused-functionality-a-bad-thing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!