3

We are a small team of data scientists maintaining some business processes in Git repository.

We have a lot of dead and unused code, things like process.R, process_1_1_0.R and process2.R (and, obviously, only one is used). The idea has always been to keep some older code 'in case something happens'.

Since all the changes are saved in Git anyway I proposed to finally get rid of all unused files. My idea was only partially accepted with a suggestion to place everything into backup subdirectories reason being that it is 'quicker and easier to recover an old working version this way'.

But does that make sense? Could somebody comment and/or reference some applicable Git workflows?

Thanks.

Pranasas
  • 597
  • 6
  • 22

1 Answers1

3

Delete it. Since it's under version control, you can recover it at any time. Keeping code that does no useful work is just a maintenance cost to pay for you and your team.

See this or this question or this blog post.

EDIT: People often talk about commented out code, like here or here:

Don’t comment out code; remove it. The problem here is that it’s very tempting never to remove old code, perhaps out of fear to lose it. Other developers may not understand why code was commented out, and leave it there. [...]

But everything said about that also applies to files containing old code, like in your case. Having a file containing unused code is even worse in my oppinion, since it's easier to forget than a commented out code block you stumble upon from time to time.

kowsky
  • 12,647
  • 2
  • 28
  • 41