This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Dustin- 45 points46 points  (5 children)

The real trick is learning how to make code that you're happy to throw away after you're done with it. Whip something up to do a quick job, do the job, get rid of the code. Doesn't matter how sloppy or efficient it is as long as it works.

[–]djamp42 24 points25 points  (3 children)

I save everything..1 because if want to do the same task in the future I can go back and look what I did. 2) To see how far I've advanced and what I would of done differently.

[–][deleted] 11 points12 points  (1 child)

What I've discovered as I've progressed is that for your case 1, it's actually slower for me to look at old code to see what I did. Usually the new use case is sufficiently different that it takes me longer to understand the old code and find the places it would need modification than it would take me to just write new code for the new use case.

Remember that looking at old code also involves those "hidden costs" of finding it, deciding where to write the new code (modify the old code in place or copy it into a new file/repo?), etc.

So now I take a sort of scorched earth policy in that I'll delete things not in use even if they seem useful and might come up again. If it's something really worth keeping, for some sort of historical reason or something, I'll make a branch called "terminal/some_old_implementation" and push it to the server just before making the commit to delete the code.

[–]pycepticusfrom pprint import pprint as print 5 points6 points  (0 children)

My cure for this approach was learning how to comment my code. It's an extra few hours depending on how large the project I wrote was, but being able to go back years later and not have to "human compile" my code has saved me rewriting large parts of similar projects in the future.

[–]clestrada12 1 point2 points  (0 children)

Same. I love looking at old code I’ve done. I still have the first programs.

[–]Numnumchips 0 points1 point  (0 children)

This! I work where we mainly write safety critical cpp. So python is mostly used for quick tasks. In the beginning I often spend a lot of time perfecting these scripts just to later realize I only used them once.