Programming Warm Ups?
ResHippie asks: "No athlete or musician would think about just diving in to the day's activity without doing some series of warm ups first. Aside from starting most computing sessions with checking email and the like, I pretty much try to dive right in to the task at hand. It usually takes me a while to get going, though. Does anyone have any routines they go through before coding (or any other work-like activity) that helps?"
coffee, a little slashdot... poking at any outstanding errors, reading through error logs from the program in question... rereading the source, adding better comments to sections that you've forgotten /again/ how they work... write a little documentation, update the changelogs...
THEN the new code.
Keep your packets off my GNU/Girlfriend!
I always scan through the new articles here on /. and Fark.com before starting the day. It sort of gets me thinking a little, and starts the day off interesting.
Drink Coffee
//Working here, trying to get the right objects from iterator
Read Email
Read Slashdot
Actually, the best way I've found to get into the zone is to leave a compiltation error from the previous day. It is the mental equivalent of a stack pointer from which you can pop all of your registers, reinitialize the idle process, and start cranking.
example
BadObject b = iterator.next();
Yes, I work in Java. Compiler will shout about bad object types, and I'm off.
Open Source Identity Management: FreeIPA.org
I don't know, five years at a University?
I work at home, and the work day starts at 0900, so this is my routine:
0830: alarm goes off
0840: actually get out of bed
0842: start brewing coffee
0844: pour cup of coffee before it's actually ready
0845 (optional): small scream as I pour hot coffee on my hands since I haven't opened my eyes yet
0846: go out on deck with copy of whatever magazine is closest to hand (generally some ancient copy of Linux Journal). Smoke cigarette, drink coffee
0859: come back in
0900: log onto computer and check for emails from co-workers
0901: quick scan through various mailing lists for security alerts and the like
0903: try to remember what I was working on yesterday when I called it a day and get back onto it
`fortune -o`
I usually start the day's coding session with a slow progression of vocal cord exercises that simulate what will be done later in the day.
Start with simple cursing. "Dammit. I can't believe I left that variable uninitialized." Then gradually build your way up to more intense grumbling, being careful not to overstrain your vocal cords. "Holy crap that goddamn idiot Jack still didn't fix that bug? That was a week ago! What does that fat sack of shit do all day long?" From loud complaining you work your way into loud yelling and screaming. "Fuck you, MSVC++! Don't tell me 'internal compiler error'! What the fuck kind of shit is this! You goddamn cocksucker! Fuck you Gates! Yeah, fuck you!" Now that your blood temperature has raised a few degrees, you can begin doing whole-body exercises. Jump up and down and scream "Fuck! Fuck! Fuck! There's no error there you shithead compiler! That's perfectly legal C++! Just compile it you fuck!" Then pick up your monitor and pretend to throw it against the wall. Start gradually at first, eventually working into really whipping your torso around. This will make sure you down strain any ligaments in your lower back when you finally do snap and start trashing your computer.
Remember people, safety first!
GMD
watch this
Obligatory Office Space quote:
Bob Slydell: If you would, would you walk us through a typical day, for you?
Peter Gibbons: Yeah.
Bob Slydell: Great.
Peter Gibbons: Well, I generally come in at least fifteen minutes late, ah, I use the side door--that way Lumbergh can't see me, heh--after that I sorta space out for an hour.
Bob Porter: Da-uh? Space out?
Peter Gibbons: Yeah, I just stare at my desk, but it looks like I'm working. I do that for probably another hour after lunch too, I'd say in a given week I probably only do about fifteen minutes of real, actual, work.
Make sure to do exercises for each part of your body:
Hope that helps,
GMD
watch this
I usually open up the interactive python session and try a couple things out. It's not really a warm up, I'm trying to learn python. I guess it could be though. Try a few lines of code out, then get down to business.
The GeekNights podcast is going strong. Listen!
This is similar to some advice I heard for writers:
When you're being really productive towards the end of the day, stop before you're finished. Then you'll have something easy to start with at the beginning of the next day.
I am staring at my hands thinking: but that's what I actually do... Maybe I should have gone to college where they teach proper technique...
Then again, taking a break from coding and reading the other replies: everyone else seems to be answering humorously, so maybe I can save my ego by saying:
of course I don't really do any of that, heh heh... that would be silly... I mean, coding is hard and I... Hey - look over there - the Matrix!!
Keep your packets off my GNU/Girlfriend!
One time Hunter S. Thompson was lecturing at my college campus (with John Belushi!) and I had the opportunity to ask him about his preferred method of preparation for a writing session.
Thompson's complete answer: "Booze and speed."
I find that starting with paper and ink is a good way to get the juices flowing. If you have a bug from a previous day write out a solution on paper, nothing serious, just jot down some notes on it, or ideas.
If you don't have something specific then I generally do as someone else mentioned and test a few things; if I find there's something broken put it on paper.
For me there's just something about flowing ink and flowing ideas. Overall I think finding small issues (if lucky) to work on at first is good because it allows one to see some progress, which is always a good motivator!
Push the envelope. Watch it bend. -Tool
That, or coffee.
dominionrd.blogspot.com - Restaurants on
Have a look at CodeKata, coding practice sessions. Doing one of these occasionally (start of each week?) may help you get into the right frame of mind/attitude.
To start a serious coding stretch, I take care of outstanding things that will be a distraction. Like, as many others have suggested, reading email, Slashdot, checking whatever web pages your mind might drift to, chatting with co-workers and boss, using the bathroom, eating lunch, etc. Then, make a cup of coffee, turn off telephone, select appropriate music, put on headphones, and start cranking.
If you can't leave your development tools in a specific state between coding sessions (ie, if you are required to or prefer to shut down compilers, editors, IDEs, and the like when not in use), then, as others have suggested, leave a syntactical error at a key location which will clue you in to where you were mentally (this is not so much warm up as a token to make the process faster next time around). Even if you don't shut your tools down, it's nice to have a quick description of what you were working on before to continue from. I often will write down a couple of key phrases on a piece of paper or yellow sticky (eg, "check interaction between reduncancy check and precomputation" or "examine compute_latency() output to be sure each event is valid") left on my keyboard.
Now, to really answer the question, I don't think anyone does any mental exercises to warm up. I also don't think they're necessary -- most of the posted answers, including mine, deal with preparing your environment for work, not yourself. The most common exception to this is ingesting caffeine -- and this is well-known to initially have a sharpening effect on cognitive ability. The most difficult part of doing hard coding is recovering the mental state, and while not exactly preparation for coding, it's the biggest step when resuming an earlier coding session, and many other posters have given good tips.
Put my fist through my alarm clock with its ding-dong death inside my ear. - The Blackjacks.
Instead, I load up the project, create remote sessions, etc. -- whatever I need to do the job -- take a look at the specific thing I need to work on, then background the whole thing and bring up some kind of logic game. Lately, it's been Bejeweled Deluxe.
I've discovered that a logic game puts me into the right frame of mind while simultaneously letting me "mull over" the work I'm about to do. I stay away from reflex-oriented games, or those involving words; they make me concentrate too closely on the game. By the time I've played a game or two I've already thought of several ways to attack the coding problem at hand, and I can get started.
Actually, the obvious (if I want to get some serious work done) is to NOT load /.
:
... open some code, any code, in the editor and hit compile. Watch it compile while I sip some tea, and when it finishes compiling start looking through the code for something to document. I don't need to actually change any code, just get my brain in code reading mode and commenting some uncommented code does this for me, not to mention gets the code documented.
... no nothing. Just me, the compiler and editor IDE, and the task at hand.
My routine when I really, really need to bust out some hardcore code is
Get caffeine in my system. A big glass of ice tea consumed while I am fixing myself the second, bigger glass that I will drink on at the keyboard.
Fire up the computer.
While that is firing up, rinse my face in the bathroom sink, hot water - really hot. As my face warms up, make it hotter. With the face oils on my hands, run them under water that is as hot as I can stand without pulling them out. Two or three minutes between face and hands.
Log into my system.
Put in my ear plugs.
(Here is the important part)
Don't start a browser session.
Don't open my email client.
Don't sign in to instant messenger.
Don't check voicemail.
Don't start the Kazaa client.
No slashdot, no hotmail, no work related emails, no fark.com, no cnn.com, no tom's hardware, no ebay, no techbargains
If you follow that formula, the inertia will be to get into the zone and stay in the zone (no distractions via phone, email, IM, whatever.) In fact if success isn't optional, I have been known to unplug my machine from the network, insuring that I couldn't fire up and of the distractions 'just for a second' even if so inclined. Get some serious work done, though.
Glonoinha the MebiByte Slayer
Before programming, thinking has a proven effect on the outcome of your endavour. I have programmed computers for about half my life (started at 15 and turned 31 last year), and thinking seems paramount when considering what to do before actually coding. It is amazing to see how many forget this basic rule of thumb.
Next, read books and standards . Not knowing that your problem has been (partly) solved already or can be solved better is a sure path to theeth-grinding reinventions of the wheel.
Then, when you're really set to start coding (after thinking for half a day, reading a book and three standards), eat. Real food.