<p>I took a data structures class in C++ last year, and consequently implemented all the major data structures in templated code.  I saved it all on a flash drive because I have a feeling that at some point in my life, I'll use it again.  I imagine <em>something</em> I end up programming will need a B-Tree, or is that just delusional?  How long do you typically save the code you write for possible reuse?         </p>

[{'answer_id': 68157, 'author': 'Chris Upchurch', 'author_id': 2600, 'author_profile': 'https://Stackoverflow.com/users/2600', 'pm_score': 6, 'selected': True, 'text': "<p>Forever (or as close as I can get).  That's the whole point of a source control system.</p>\n"}, {'answer_id': 68161, 'author': 'Scott Swezey', 'author_id': 9439, 'author_profile': 'https://Stackoverflow.com/users/9439', 'pm_score': 1, 'selected': False, 'text': '<p>I keep backups of all of my code for as long as possible. The important things are backed up on my web server and external hdd. You can always delete things later, but if you think you might find a use for it, why not keep it?</p>\n'}, {'answer_id': 68167, 'author': 'Aupajo', 'author_id': 10407, 'author_profile': 'https://Stackoverflow.com/users/10407', 'pm_score': 0, 'selected': False, 'text': "<p>Source control, keep it offsite and keep it for life! You'll never have to worry about it.</p>\n"}, {'answer_id': 68170, 'author': 'John Millikin', 'author_id': 3560, 'author_profile': 'https://Stackoverflow.com/users/3560', 'pm_score': 2, 'selected': False, 'text': "<p>If I use it, it gets stuck in a Bazaar repository and uploaded to Launchpad. If it's a little side project that pitters out, I usually move it to a <code>junk/</code> subdirectory.</p>\n\n<blockquote>\n  <p>I'll use it again. I imagine something I end up programming will need a B-Tree, or is that just delusional?</p>\n</blockquote>\n\n<p>Something you write will need a B-tree, but you'll be able to use a library for it because the real world values working solutions over extra code.</p>\n"}, {'answer_id': 68202, 'author': 'dawnerd', 'author_id': 69503, 'author_profile': 'https://Stackoverflow.com/users/69503', 'pm_score': 0, 'selected': False, 'text': "<p>I have code from many, many years ago. In fact, I think I still have my first php script. If nothing else, it's a good way to see how much you have changed over time.</p>\n"}, {'answer_id': 68373, 'author': 'codefin', 'author_id': 3745, 'author_profile': 'https://Stackoverflow.com/users/3745', 'pm_score': 0, 'selected': False, 'text': "<p>I agree with the other posters.  I've kept my code from school in a personal source code repository.  What harm does hanging on to it really do?</p>\n"}, {'answer_id': 68393, 'author': 'rjray', 'author_id': 6421, 'author_profile': 'https://Stackoverflow.com/users/6421', 'pm_score': 1, 'selected': False, 'text': '<p>I still have (some) code I wrote as far back as college, and that would be 18 years ago :-). As is often the case, it is better to have it and never want it, than to want it and not have it.</p>\n'}, {'answer_id': 68401, 'author': 'MikeJ', 'author_id': 10676, 'author_profile': 'https://Stackoverflow.com/users/10676', 'pm_score': 0, 'selected': False, 'text': '<p>I would just put it on a disk for historical sake. Use the\n<a href="http://www.sgi.com/tech/stl/" rel="nofollow noreferrer">Standard Template Library</a> - one mistake people make is assuming that thier implementation of moderate to complex data structures are the best. I can\'t tell you how many times I have found a bug in a home grown B-tree implementation.</p>\n'}, {'answer_id': 68430, 'author': 'Daniel Spiewak', 'author_id': 9815, 'author_profile': 'https://Stackoverflow.com/users/9815', 'pm_score': 2, 'selected': False, 'text': "<p>+1 to keeping code forever.  In this day and age, there's just no reason to delete data which could possibly be of value in the future.  Even if you don't use the B-Tree as a useful structure, you may want to look at the code to see how you did something.  Or even better, you may wish to come back to the code someday for instructional purposes.  You'll never know when you might want to look at that one particular sniblet of code that accomplished a task in a certain way.</p>\n"}, {'answer_id': 68435, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Keep everything! You never know when it will save you some work. About a year ago I needed some c code to parse an expression, tokenize it for storage, and evaluate the results latter. Ugly little piece of code.. But is seemed familiar, as it should have- I had to do a post-fix evaluator in college (30 years ago)- and still had the code. Admittedly it needed a little clean-up, but saved me a couple of days of work. </p>\n'}, {'answer_id': 362785, 'author': 'DiningPhilanderer', 'author_id': 30934, 'author_profile': 'https://Stackoverflow.com/users/30934', 'pm_score': 0, 'selected': False, 'text': '<p>I implemented a red black tree in Java while in in college.  I have always wanted to find that code again and cannot.</p>\n\n<p>Now I do not have the time to recreate it from scratch since I have three kids and do not develop in Java.</p>\n\n<p>I now keep everything so that I can relearn much faster.  I also find it fascinating to see how I did something 1, 5, 10 years ago.  It makes me feel good because I either did it right or I am better now and would do it differently</p>\n\n<p>If I ever go back to college to give a lecture to future students it in on the list of things to do:</p>\n\n<p>Save everything...</p>\n'}, {'answer_id': 362807, 'author': 'Matt Jacobsen', 'author_id': 15608, 'author_profile': 'https://Stackoverflow.com/users/15608', 'pm_score': 3, 'selected': False, 'text': "<p>-1 to saving everything that's ever produced. I liken that to a proud parent saving every single used nappy ever to grace the cheeks of their little nipper. It's shitty and the world doesn't benefit from it's existence.</p>\n\n<p>How many people here go past the first page in google on a regular basis? Having so much crap around only seems to make it difficult to find anything useful.</p>\n"}, {'answer_id': 362827, 'author': 'Mike Dunlavey', 'author_id': 23771, 'author_profile': 'https://Stackoverflow.com/users/23771', 'pm_score': 0, 'selected': False, 'text': "<p>I'm a code packrat, for better or worse, but I guard it, because sometimes it's client-confidential.</p>\n\n<p>On occasion, this has been really useful, like if a client lost their stuff, or their documentation.</p>\n"}, {'answer_id': 362836, 'author': 'Patrick Desjardins', 'author_id': 13913, 'author_profile': 'https://Stackoverflow.com/users/13913', 'pm_score': 0, 'selected': False, 'text': "<p>I lost a lot of old code (from 10 years ago) because of computer failure that wasn't backed up but in fact I do not really care because I do not really want to see code that is programmed in very old language. Most of this code was written in VB5...</p>\n\n<p>I agree that now it's easy to keep everything but I think sometime it's good to clean up our backup/computer storage because it's like in the real world, we do not need to keep everything forever. </p>\n"}, {'answer_id': 1095429, 'author': 'Pup', 'author_id': 125505, 'author_profile': 'https://Stackoverflow.com/users/125505', 'pm_score': 0, 'selected': False, 'text': "<p><strong><em>Forever</em></strong> is the beauty of the electronic medium. That's one of the most attractive aspects for me.</p>\n\n<p>But, the keeping of it depends on your coding style, and what you do with it.</p>\n\n<p>I'd suggest tossing your code if you're the type that...</p>\n\n<ul>\n<li>Never looks back.</li>\n<li>Would rather re-write from your memory to improve your craft.</li>\n<li>Isn't very organized.</li>\n<li>Is bothered by latent storage to no end.</li>\n<li>Likes to live on the edge.</li>\n<li>Worships efficiency of memory.</li>\n</ul>\n\n<p>Logical reasons for tossing could would be...</p>\n\n<ul>\n<li>It bothers you.</li>\n<li>It disrupts your workflow by getting in your way.</li>\n<li>You're ashamed of it.</li>\n<li>It confuses you and distracts you.</li>\n</ul>\n\n<p>Like anything that takes up physical space in life, it's value is weighed against it's usefulness.</p>\n\n<p>All my code is kept indefinitely, with plans to return to it at some point, reflect, and refactor. I do that because it's fun to see my progress, and provides very accessible learning experiences. Furthermore, the incorporation of all my code into a consolidated framework is something I work towards all the time.</p>\n"}, {'answer_id': 1595258, 'author': 'Nick Haslam', 'author_id': 79055, 'author_profile': 'https://Stackoverflow.com/users/79055', 'pm_score': 0, 'selected': False, 'text': '<p>Forever...</p>\n\n<p>Good code never dies. ;)</p>\n'}, {'answer_id': 1595356, 'author': 'mouviciel', 'author_id': 45249, 'author_profile': 'https://Stackoverflow.com/users/45249', 'pm_score': 0, 'selected': False, 'text': '<p>I don\'t own most of the code I develop: my employer does. So I don\'t keep that code (my employer does - or should).</p>\n\n<p>Since I discovered computing, I wrote code for devices that no longer exist in languages that are no longer worth. Maybe there is some emulator but keeping that code and running it would be nostalgia.</p>\n\n<p>You can find <a href="http://en.wikipedia.org/wiki/B-tree" rel="nofollow noreferrer">B-tree</a> information (and many other subjects) on Wikipedia (and many other places). There is no need to keep that code.</p>\n\n<p>In the end I keep only code that I own and maintain.</p>\n'}]
['https://Stackoverflow.com/questions/68150', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7545/']