Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm a novice programmer and I occasionally come up with ideas that I think will be handy on future projects. Having an art background, I used to keep a sketchbook. I would go back through these sketchbooks and they might go and inform future projects. I'm trying

Do you keep your scratch code from past projects to track how your past projects developed? Do you store that along side the final product? Do you keep a "code sketchbook"? What is a good way of capturing these past ideas and making them accessible?

I saw this thread, and I'm more interested in capturing those disjointed ideas and solutions that and problems that I come up with. I like the idea of the wiki, but I also like the idea of something that is easily executable in EMACS.

share|improve this question
1  
Ideas, yes. Code not running in production, no. It will never be what you need anyway. – user1249 Aug 7 '12 at 16:23
I should have included in my above question "project related scratch code", or that may be a separate question altogether. – Chow Aug 7 '12 at 21:57
Generally no. In a very few cases - like functional proof-of-concept code, then perhaps yes. – user1249 Aug 7 '12 at 23:27
Just for context I do mostly R programming where much of my coding is done in an interactive session to understand the data I'm working with. – Chow Aug 29 '12 at 16:04

5 Answers

I generally do my tinkering and new tech investigation on my home box. I just keep them all in their own directory under a general "Experiments" directory. They're usually not directly applicable, but they're often a good reference (e.g., when I was figuring out how to process Java annotations). I keep thinking I'll release some of the more self-contained ones as open source, but I never seem to get around to making a SourceForge or GitHub account.

share|improve this answer

I actually keep a local wiki of code snippets and ideas. Its a really nice, productive way of organizing the small things that you don't immediately need. In general, there are a few rules you should follow if you don't want it to get out of hand:

  • Give the snippets long, understandable names. This way, you know exactly what the snippet is about and how it could be used.
  • Comment like crazy for the same reasons as above.
  • Setup a personal organization system that suits your exact needs.

I recommend using MediaWiki or MoinMoin, but there is a whole list over at Wikipedia.

Generally, I make a page for each code snippet/idea, and write a history and description of each. I make them as search friendly as possible so that I can fins them fast and easy.

Of course, you can't execute within the wiki, but that's what jsFiddle, Ideone, and Codepad are for. Also, you can always run the code on your machine.

share|improve this answer
1  
A local wiki is a good way to go – waffleman Aug 8 '12 at 13:43

I wonder if it is a good idea to create a "scrap"; "scratch" or "sandbox" area in the source repository, specifically for experimental code, snippets & incomplete thoughts?

It might also have the beneficial side-effect of de-sanctifying the repository in people's minds.

share|improve this answer
If this were stated as an answer instead a question, I'd +1 it. – DarenW Aug 9 '12 at 20:08
Well, I am not yet confident that it is a good idea. – William Payne Aug 9 '12 at 20:12
I would agree with the point of "de-sanctifying the repository". I have code snippets and small tools that I think are useful but I am not confident to put into mainline code yet. But would like to allow colleagues to try – justintime Aug 24 '12 at 6:45
1  
I now have both a "sandbox" area, for trying new things out, and a "research" area, for throwaway exploratory data analysis and other R&D-ish scripts. – William Payne Aug 24 '12 at 23:00

I have a directory for programming, and I keep different subdirectories in it for different languages (Programming/CPP, Programming/Ruby, Programming/Lisp, etc.) and in each of these directories, I keep a folder named "snippets" where I save reusable code in that language. The only problem with this is that files start to pile up in it, and it can get out of hand. If you do this, try to keep it organized.

share|improve this answer

I used to, but at some point over the years it became just too big a pile o' code and I started throwing out huge chunks of it. It can be beneficial as long as it doesn't grow out of control.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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