Thursday, March 11, 2010

Joel's 12 steps to better code - in HEP

This is inspired by Joel's 12 steps to better code:
http://www.joelonsoftware.com/articles/fog0000000043.html

Although we are high energy physicists, most of our time is spent writing code (in C or C++). So I thought it would be curious to see how we measure up to the best practices advocated by professional programmers.

  • Do you use source control?
Yes. We have 3-4 people actively working on the code in Chicago and about 2 people in Italy, so version control was very useful. We started with CVS provided by ATLAS, and got upgraded along with everyone else to SVN in 2009.
  • Can you make a build in one step?
Yes. We have a bash wrapper that sets up and builds the software in one step. However, some environment variables need to be set by the user. For developers / active users, this is not an issue, but newbies often have trouble.
  • Do you make daily builds?
No. That would be useful, and some members of the team suggested it, but we never got around implementing it. As a matter of fact, we don't even have a set of robust test cases. I had committed a simple big-picture test a while ago, but it never caught up and is probably deprecated by now.
  • Do you have a bug database?
No. But it would be very useful! I remember cases when bug fixing was delayed and sometimes forgotten altogether until someone else got hit by the same bug (superstrip map format, anyone?)
  • Do you fix bugs before writing new code?
No. And that's a problem. In academia, we are often under pressure to produce results, even with buggy code. So we end up introducing temporary workarounds and forgetting about them...
  • Do you have an up-to-date schedule?
Yes. We don't have a formal centralized schedule, but it is constantly brought up in weekly meetings (and thus kept in agenda pages), with specific tasks and approximate completion dates. Interestingly, the completion date estimates are almost always a factor of two shorter than what they end up being in practice.
  • Do you have a spec?
No. But I don't think we could. New ideas pop up almost every week, so the spec document would be completely fluid. Effectively, we have that in the agenda pages for the weekly meetings.
  • Do programmers have quiet working conditions?
No. We have offices, but we usually share them with another grad student. This results in frequent chatter about stuff unrelated to work, with the subsequent drop in productivity.
  • Do you use the best tools money can buy?
Yes. Lucky us - we can get academic discounts on fancy electronics design software, or sometimes just get it for free. And the GNU compiler collection is free anyway - and it's very good!
  • Do you have testers?
Haha, testers in academia? On a more serious note, first-year grad students effectively act as testers before they learn enough to start coding new projects themselves.
  • Do new candidates write code during their interview?
No, we are physicists after all, not programmers. Some people starting a Ph.D. in high energy physics don't even know how to close an emacs window and are completely clueless when the compiler throws an error message. But to be fair, most of us had quite a bit of coding experience before coming to grad school.
  • Do you do hallway usability testing?
In a way, we do. A newly written feature often immediately gets into the hands of a beginning graduate student who will run it and report any problems or unexpected results.

Cooking attempt # 1

So Meng made a bet with me that I won't be able to cook a meal entirely on my own. Although I HIGHLY dislike cooking, I just had to prove her wrong. So here goes:

Homemade Chicken Fettuccine (from allrecipes.com).

1 yellow pepper - $0.26
1 broccoli - $0.58 (will last for one more meal)
whipping cream - $1.79
parmesan cheese - $2.38 (will last for several meals)
8oz mushrooms - $1.49
1 club of garlic - $0.33 (will last for several meals)
pack of butter - $3.49 (will last for several meals)
1 garlic salt (spices) - $0.99
3 chicken breast halves - $5.69

Total cost, weighting multi-day items appropriately:
0.26+0.58/2+1.79+2.38/4+1.49+0.33/4+3.49/6+0.99/10+5.69=10.88

Thus, the total cost is: $10.88
It took 2 hours of my time (excluding shopping time), and will feed 2 people two times.

Outstanding Asian Movies

A few years back I discovered that some movies by Chinese filmmakers resonate particularly strongly with me. I especially love movies that describe life in China under Japanese occupation and later during Cultural Revolution.
The following movies include both mainline blockbusters and rare gems. Some of them I simply found beautiful, while others left me thinking for days.


Zhang Yimou (China):
  • Shanghai Triad
  • The Road Home
  • To Live
  • The Story of Qiu Ju
  • Not One Less
  • Raise the Red Lanterns
  • Hero
China (other):
  • Lust, Caution
  • Xiu Xiu (The Sent Down Girl)
  • Chungking Express
  • Balzac and the Little Chinese Seamstress
  • 2046
  • Crouching Tiger, Hidden Dragon
Kim Ki Duk (Korea):
  • Samaritan Girl
  • 3-Iron
  • Spring, Summer, Fall, Winter... and Spring