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!
Load Slashdot...
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`
Kick on the mp3 player, stretch out the hands (RMI), check the mail, update the source, check for user posts, drink the coffee, kill the lights, crank the music, and let the code begin.....
I write code.
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
Lots and lots of methamphetamine.
'nuf said.
what the hell moderator on crack modded this as informative? man, that's all i need: my coworkers start doing this warmup routine every day! i'm going to blame it all on slashdot!
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.
Well?
(It took me 8 seconds to type this...)
Make sure to do exercises for each part of your body:
Hope that helps,
GMD
watch this
I like to leave the day off with a test that fails...
Then, the next morning... I run a "make test"
Fixing the failed test usually gets me back into the flow. If not, I write more tests.
If that doesn't get the juices flowing... I write docs and refactor code.
--Phillip
Can you say BIRTH TAX
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!
I figure when my pulse reaches 140 BPM at rest my brain is getting enough blood to acheive it's full potential.
Hollow words will burn and hollow men will burn.
When I am writing code I like to use the product for a while and get the feel of what is going on and visualise all the functions that get called while it is executing. Its imprtant to get a vey basic version of the system going to get the idea of how its executimg. Thesame goes for hardware design. When I was designing a cpu it really helped to see the schematic view of the system executing instructions and the values flying around. Much easier to understand than looking through the design.
When writing a language or an input method try it out before writing any code. When I wrote a language called chump I wrote whole pages of code in it and only then started writing the compiler. I had to change many things in order to make it usable which I wouldnt have guesses if I didnt use it for a substantial ammount of time.
Mouse powered Chips, Open source Processors and Lego
generally, if i haven't reloaded the file or quit vim, i'll do a 20u and playback changes with ctrl-r. with screen and vim's split windows i can generally keep nearly every file open that i was working on before i went home.
one screen window for model, one for view, one for controller, one for unit tests, one for templates, etc... then another putty multitailing logs, set transparent and on top with vitrite.
then i hope and pray that i don't get laid off.
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!
after that I read some online comics, write some emails, and start reading fark.
Then I usually head out to lunch w/ co-workers. Around 2 pm or so, I get back and read slashdot for a while. that usually fires me up or pisses me off or something, and I then jump right into some REALLY intense hard core coding... for about 5 minutes, then I log off, go home, and drink some beer.
First thing: always check out the error logs from the sun servers(emailed to me every morning). Get my coffee...read slashdot....there goes an hour. by the time i'm done reading...reload and there is a few new articles...another 20 minutes gone. then start with a new compile to see all the problems from the previous day.
I find that opening the bug list and simply pick one and start then is MUCH more productive than reading any e-mail or web sites first thing in the morning. I still grab a coke first thing, but have found that if I read e-mail or any other tak first thing, when my head is somewhat clear, I am MUCH more efficient, and can usually get on a roll easier and have most of my work completed before lunch. It feels good to have a somewhat clear concience. In addition to this method I have found I can think much better. I feel distracted and n olonger want to "work" after I browse the web or read e-mail. It just works better for me. No warm-ups, just...code first thing ...maybe after you grap some caffiene.. I am usually doing a full get from the repository while I am grabbing the caffiene.
Step 1: Locate Caffiene source. Step 2: Devour at least 24Oz of source to initiate step 3 Step 3: Get your jivin' tunes in order, crank-em up; Techno makes you feel smart and gooooood. Step 4: Drink while coding, keep a good supply of moozic on hand so you dont listen to the same stuff.. Step 5: collapse for the night and sleep Step 6: wake up and repeat!
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."
Just don't stop... seriously... When I'm on a roll, I don't stop for anything. Just give me an IV and some caffine. I stop when the program is done- or my blood sugar level drops below 10.
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
"Does anyone have any routines they go through before coding (or any other work-like activity) that helps?""
:)
Not exactly. I usually go straight from my bed to the office. That's why I have a beard and an outfit that I don't want to be seen in public in, causing me to brown-bag lunch for today. (Incidentally, I pack a banana in there because they require no preperation, very efficient food I might add.) Then, I come in, and drink 3 cups of coffee, though the third cup is pretty bitter. By then, it's about 9:30, so I catch up on the news. I post a little bit on Slashdot, those stupid pro-MS ppl get on my nerves. Don't they see that they can download the source code to other people's apps, decipher their coding style, rummage through all of their code, and fix the problems that come up with it? Anyway so I gotta teach those Microsofties what a real OS is. God they're so stupid with their ease of use and their GUI, it's like they don't know how to operate a caps-lock anymore. Oh anyway uh around 10:30 I wrap up my news gathering and get straight to work. I fire up my email and read the joke of the day and carry on my conversations about last week's episode of Enterprise. Unfortunately, we won't see new eps of Enterprise until September so instead we discuss the good old days before Babylon 5 came along inexplicibly rose to popularity. But that's just an aside, I really check my email to see what new defects and updates I need to do to the code. Usually there's something I need to run past a coworker. So I'll go over to him and then we'll have a brief 20 minute discussion about it and how the war in Iraq is going. Oh! Crap! It's 11:30, we better go to lunch early so the lines are short and we can get back in time. At 1:30pm, I come back from lunch and sit down ready for work! Then, there's usually a meeting. So I attend that little hole in time for about 2 hours. At 3:30 I check up on my posts on Slashdot to make sure some dumbfuck moderator didn't mod me as redundant for my Simpsons quote that should have been a +5, Funny. Afterall, that same Comic Store Guy quote was +5, Funny quite a few times after that. Man, I swear the mods are against me. Anyway, at 4:30 I really sit down and work for the next 2 hours, then I go home.
Hope this warmup exercise helps.
"Derp de derp."
That, or coffee.
dominionrd.blogspot.com - Restaurants on
Any sufficiently advanced technology is indistinguishable from magic. (Arthur C. Clarke)
how about some black coffee, and 1.2Gb of fayrouz?
what are you, my conscience?
The lunatic is in my head
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.
apt-get install typespeed and I play a game or two. Gets my fingers going, and ready to type for the rest of the day. Nothing is more annoying than trying to type and solve the world's problems when you have fat fingers in the morning.
--Robert
jack off once or twice to get me going.
Karma: The shiznight, mostly because I am the Drizzle.
our small programming office looks like this:
...
one computer
one scanner
one big-screen projektor
ten typ writers
one BIG chalk-board.
two secretary (scanning)
five programmer.
we OCR the programms from the typ-writer.
the big-screen projektor is visible to all.
and we can see the progress.
since we are communists we just show up
when we have solved the problem.
it's not like we FORCE anyone to work,
we acctually like what we are doing.
you get coffee after 3 PM with some
cake
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.
I do 1 hour of excercise before coding showering and getting down to code. It adjusts my attitude, focusses my mind, reduces my bug count. Wonderful.
Oh, yeah, I keep a large cup of coffee and a larger bottle of water next to me while I excercise.
I usually do my stretches first, then weapon practise in the backyard, then go through all my katas and sparring techniques....
Kung fu does wonderful things for the mind and body. All the physical and mental value of Yoga but about 10 times more fun.
Stonewolf
When I find myself slow in the morning, it is usually because I am not exactly sure what it is that I am supposed to be doing. My solution has been to plan the next day, particularly the first tasks, before leaving at the end of the previous day. The other approach is not to worry about being slow in the morning. If fact, you may want to skip the mornings altogether on the basis that productivity is particularly low at that time.
LOL. The moderator is a 'tard.
I'm not really a web designer, I just play one on the Internet.
Perhaps, but if you're (finally) in Deep Hack Mode, you shouldn't stop - I reckon.
zWhat would an EWOULDBLOCK block, if an EWOULDBLOCK could block would? -- me
When a CS project is due this tends to be my warmup.
When the project first comes out I look at it and determine how long it will take me. Then that night i drink precisly 2 Old English 40's (no more, no less) and determine how long it will take to do while drunk. Then i turn on some Techno and attempt to start coding. Once i forget the name of the file i close it and go play q3 or starcraft (starcraft has to be the best drunk game ever). This continues for a few more days while i have all of the files created but nothing is in them. The day it is due I wait till the last possible minute and turn on some techno and get it done 1 minute before its due.
All of this hard work can guarantee a C in the class (i got a 105% on the final which helped) and i never have to take a p[rogramming class ever again.(my major is NOT CS, i would kill myself because i hate programming)
Just GET TO WORK! No wonder so many of our jobs get outsourced over seas.
I always check Megatokyo, Penny Arcade, Userfriendly, Get Fuzzy, Dilbert, and NonSequiteur. After that, I'm ready for lunch! -PS
Here's a tip: try pissing and shitting BEFORE you take your shower...your cubemates (and Catherine and the kittycat) will thank you for it.