This is (pehaps bad) habit I have formed and I am wondering if others have experienced the same thing and strategies for managing it.
A lot of times I will write a fair amount of experimental throw away code in the course of coming to the most effective solution. Sometimes complex loops and arrays and various functions that have a fairly involved internal logic. For me coding is an iterative process so I like to keep old partially working code around commented out so that I can refer to it as I am working on a slight variation of the function. Or in some cases quickly go back if a particular change doesn't work. But sometimes the commented code really gets in the way of being able to read through the overall flow of a particular code segment in a specific file. And too much of it becomes a real distraction. I realize I can do a lot of check in check outs to a repository (subversion) etc and delete the temp code knowing it is backed up. But I hate to check in broken or partially completed code.
What I really need is a highly functional "scratch pad" while working on code. Easy to hide expose. Maybe I haven't mastered the fine art of folding comments in my IDE. But I was wondering what people do to deal with this kind of problem?
Perhaps a very focused scratch pad app would be useful (preferably OS X). Something that integrates unit test production as well. Something where you could focus on a very narrow scope but still have some interpreter built in to actually "run" the function independent of a larger project. Add in a quick way to run or test the function, object or code segment in the scratch pad and something that would encourage the writing of units tests as you write the temporary code. And when you get the code segment working you can quickly merge back into your main project.
Does such an app exist? Does anyone else have this problem? Strategies for dealing with it?
I know that XCode has a nice "snapshot" feature that would help in this problem. I am doing a lot of work in Flex Builder these days. Wondering what the actionscript junkies out there do. Sometimes I go back and forth between flex builder and textmate. Any other strategies?
Update: To the people proposing git. What about browsing and keeping the code visually available? I am kind of partial to the Cornerstone app on OS X for subversion access. Are there any nice GUI frontends to git? More specifically, how can you keep the temp code segments a single command tab or icon click away while working within your IDE?