-4

Often I change code but I don't know if I might need the old one, I can leave it under comment but then I find myself with lots of green lines while I hardly can read the real code. Thanks.

marked as duplicate by gnat, Pieter B, TZHX, Thomas Owens Feb 2 '17 at 9:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5

You use a source control system (like Subversion or Git) which keeps track of old versions of the code. Then you can safely delete unused code, since you can always roll back if you discover you deleted something by mistake.

  • I would not suggest subversion. Git is enough :D – Napolux Feb 2 '17 at 8:40
  • 2
    better: »like Mercurial or Git« – Thomas Junk Feb 2 '17 at 8:47
2

You might use the following options:

TODO-comments

If you make a change in your source code, you can first comment out the old part and add

//TODO: your description

above it.

After some testing you can then search in your code for "//TODO:" and clean it up.

Version control system (e.g. git)

Additionally you should use a Version control system, e.g. git. this gives you the possibility to roll back to any version you want and to add a comment to your changes when you push them.

Archive folder

If you decide that you don't need a software project anymore (e.g. because you don't have enough time or your priorities have changed), you should create an archive-folder where you move your old projects to.

Not the answer you're looking for? Browse other questions tagged or ask your own question.