Is removing unused functionality a bad thing?

2019-07-10 06:39发布

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.

5条回答
别忘想泡老子
2楼-- · 2019-07-10 07:18

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. :-)

查看更多
贼婆χ
3楼-- · 2019-07-10 07:24

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

查看更多
Anthone
4楼-- · 2019-07-10 07:36

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

查看更多
Lonely孤独者°
5楼-- · 2019-07-10 07:39

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...

查看更多
姐就是有狂的资本
6楼-- · 2019-07-10 07:40

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.

查看更多
登录 后发表回答