Code Like a Chef: Shave Seconds
Rene once told me about watching a cook measure ingredients for a recipe. The cook placed a bowl on the scale, then hit tare to reset it to zero. He added (let’s say) 425g of flour, hit tare, 75g of sugar, hit tare, 75g of brown sugar, hit tare, and so on.
Rene said, “Why would you hit tare? Every time you hit tare, you have to put your spoon down, then pick it back up again. Just do the math in your head. Adding 75 to 25 isn’t hard.”
Hitting tare takes only a second, but Rene might do it fifty times a day. Avoiding it is one of hundreds of ways he’s figured out how to shave seconds off repetitive tasks. If he’s walking to get flour, he finds a bowl along the way instead of making a separate trip. When cutting the blue painter’s tape used to label deli containers, he uses a spoon instead of a knife if that’s what’s in his hand. He eats food scraps instead of walking to the trashcan to throw them away.
If Rene gets two minutes faster every day, he’s got an extra ten minutes by the end of the week. Ten minutes means he can add another project to his prep list. After a year, he’s doing twice as much work as the new guy, just by shaving a few seconds here and there. The cumulative effect is why the chef at the best restaurant in the country can tweeze micro-herbs onto a dish during a twenty-course meal, while the guy at Cracker Barrel barely has time to drop a pinch of chives on your microwaved cup of potato soup.
It’s about more than saving time. It’s about cultivating the discipline of continuously asking, “Is there a better way to do this?” The process of daily incremental improvement over the course of a career is one of the differences between being good and being great.
I’m preaching to the choir. Optimizing inefficient processes is second nature to coders. Below are ways I save time on tasks I do dozens of times a day, but I’d love to learn more.
Keep my hands on the keyboard
- Use the touchpad instead of a mouse, and crank up acceleration.
- Use ⌘W to close tabs,⌘Tab to switch applications, ⌘R to refresh the browser. Use tab judiciously in the console.
- Use Quicksilver or Alfred to launch applications with ⌘Space.
- Drill keyboard shortcuts for Sublime Text 2 (Multiple Selection and Goto Anything are life changing). Shortcut foo is a good place to start, though I learn better in my editor.
- Identify where I type too much and make macros. Git autocomplete and bash shortcuts are good places to start.
- Use Spork to speed up my testing suite. It can’t imagine TDD without it.
- Run tests directly in Sublime.
- Use mocks and stubs instead of ActiveRecord.
- Only run the tests that need running. No need to run the whole suite every time.
- Use reload! instead of restarting the Rails console.
- Use Harvest OSX app instead of the browser.
- Use divvy to manage windows
- Use Gmail keyboard shortcuts.
- Turn on Send and Archive in Gmail.