Best Practices for Removing Unused Code

后端 未结 8 1225
花落未央
花落未央 2021-02-07 17:56

I\'d like to know what people\'s best practices are for removing unused code. Personally I\'m a fan of deleting (not just commenting) anything that\'s not currently being used.

8条回答
  •  执念已碎
    2021-02-07 18:35

    I'm also a fan of deleting unused code.

    If I know that the code can be helpful later, I created a branch before deleting the code from the trunk (we're using subversion - so creating branches is very cheap and easy). This allows me to easily get that code back once/if it is needed.

    For example, if you have a new feature, which won't be completed for a release, this procedure allows to remove the partial feature from trunk, but you will be able to add it back once you're gonna finish it.

提交回复
热议问题