Could someone explain the pros of deleting (or keeping) unused code?

Here are some reasons why unused code should be removed:

  • For anyone new working on a project, they not only have to understand
    the working code, they have to understand unused material also. This
    is wasted time and creates confusion.

  • There is a danger that at some time, someone will make a change
    which inadvertently involve the ‘dormant’ code and can introduce
    bugs. I know it’s happened on projects I’ve worked on.

  • The maintenance of any code is an administrative burden. By preserving
    old redundant code that burden is increased. For example, merging changes in the main branch becomes harder because there is more code to work through and more possibility to make a mistake.

  • What happens over time is that more and more old unused code is added
    to the codebase. This increases the confusion, potential
    misunderstanding and administrative overhead.

  • The chances that the unused code will ever be used again is very unlikely. With time that possibility of re-use diminishes. If code is to be removed and is considered important enough then the code can be branched off and documented.

  • Any personal feelings that a coder may have about code they may have
    worked hard on are understandable. But part of being professional
    requires that those thoughts have to be put to one side for the better
    good. Time stands for no-one and there is no place for preserving historical code in a working codebase.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)