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

0

2 Answers 2

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.

2
  • I would not suggest subversion. Git is enough :D
    – napolux
    Commented Feb 2, 2017 at 8:40
  • 2
    better: »like Mercurial or Git« Commented Feb 2, 2017 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.