September 6, 20121 Comment

Code Like a Chef: Layer Simplicity

"A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works and cannot be patched up to make it work. You have to start over, beginning with a working simple system."

-John Gall

Pictured above is a dish from the five course meal that my best man, Rene De Leon, prepared for my wedding. Rene is a world class chef: over the last seven years he's worked at the first, second and seventh best restaurants in the world, and currently serves as sous chef at Next, the 2012 James Beard Award winner for Best New Restaurant in America.

Though it's a complex dish, there's nothing complicated about making it: place thinly sliced potatoes in a single layer on a sheet tray, drizzle olive oil, salt, and roast until GBD - "Golden Brown Delicious". Trim, salt, and saute green beans. Give pork a 12 hour salt-water bath, dry it, sear it, thow it in the oven.

The complexity of the dish comes from layering simplicity. The ingredients are common vegetables and meat purchased at the Pike's Place Market. The techniques - roasting, slicing, sautéing, saucing - are thousands of years old, yet are still used by anyone who's ever tried to cook Thanksgiving dinner.

This was the most surprising part of my culinary education: great chefs aren't great because they do complicated things, but because they ruthlessly execute on simple tasks, and then combine the results. Alinea has a dish with 86 components, yet co-owner Nick Kokonas maintains in the Alinea Cookbook that, "there lies the real surprise to these recipes: none of the techniques is difficult taken alone."

Though counter-intuitive, my progress as a developer is marked by my ability to write simple code. When I was first learning Ruby, I wrote big messes of spaghetti code - every method was trying to do too much, and I was trying to be too clever. Coming back to it now, the code is hard to test, hard to maintain, and hard to understand.

Today, I try not to have methods longer than five lines, and I try not to cram too much into a single object. Bob Martin calls this the Single Responsibility Principle - the idea that "A class should have one, and only one, reason to change."

In The Pragmatic Programmer, Andrew Hunt and Dave Thomas write:

“Early on we are taught not to write a program as a single big chunk, but that we should ‘divide and conquer’ and separate a program into modules... It’s easier to write relatively small, self-contained components than a single large block of code. Simple components can be designed, coded, unit tested and then forgotten - there is no need to keep changing existing code as you add new code.”

Simplicity is easy to delegate. It's easy to train the new guy on, and improve upon. It’s hard to do complicated things consistently well, but with practice, you can master simple techniques.

Layering simplicity yields rich results. I'll leave you with these pictures of the wedding cake Rene made for us. He called it a "Fruit Opera", and its flavors were anything but simple.

If you found this post interesting, you may want to check out others in the Code Like a Chef series: 

The photos in this post, and most of this series, were taken by the ridiculously talented Devin David of Real Good Studio.

Want access to more articles like this?  Subscribe now to stay up to date on the latest from Table XI 

August 30, 201212 Comments

Code Like a Chef: Work Clean

There are a dozen opinions on any given cooking technique, but in the Alinea kitchen, when you say "TK says..." that's the end of the discussion.

Thomas Keller is considered by many to be the best chef in America, and almost certainly the most influential. His NYC restaurant, Per Se, is ranked the sixth best restaurant in the world (edging Alinea out of the spot it held in 2011). In 2003 and 2004, his The French Laundry, was named the best restaurant in the world - the first American restaurant to hold the honor. Grant Achatz, chef of Alinea, spent six years at the French Laundry - and so influential was TK's friendship and mentorship that Grant named his eldest son "Keller".

In Ad Hoc at Home, TK says:

Being organized - as we say in our kitchen, 'working clean' - is a skill to develop. We call it mise-en-place, French for, literally, ‘put in place.’ The term can be very specific, referring to ingredients needed to complete a recipe, measured out and ready to use, or it can be more general: are you organized, do you have everything you need to accomplish the task at hand?

Good organization is all about setting yourself up to succeed. It means getting rid of anything that would interfere with the process of making a recipe or preparing an entire meal. If you are in the middle of preparation, you don’t want to stop and find the proper pot, or dig around in the cupboard for an ingredient: that opens you up to distractions and errors...

When I peel an onion, I get rid of all the onion skin before I begin slicing it... When you finish with a pot, wash it. Clean as you go to avoid clutter; clutter interferes with the cooking process. Things get in your way when you’re not organized. Clear your path.

Being organized is the first and most important part of cooking.

Working clean is the most valuable concept I have adopted from the kitchen, for I am not an organized person by nature. At the office, working clean takes two forms. First, I keep my physical workspace clean. Dirty dishes, papers and knick knacks cause me visual distraction.

More importantly, I am continually cleaning my virtual workspace. If I’m not careful, by mid-afternoon my desktop looks like this:

Every file I’ve touched throughout the day is open. I’ve got a couple open docs, maybe a spreadsheet or two, unrelated to what I'm working on. Email's up, begging for my attention. I see guys brag on twitter about how many browser tabs they have open at the end of the day. I don't get that. Forty open tabs are a sign of a disorganized and unintentional mind. It's sloppy.

When I'm on my game, my desktop looks like this:

Everything is put in place. My editor takes up the left two-thirds of my external monitor - tests on the left, production code on the right. Terminal goes in the top right, time clock below that. My browser stays below on my laptop monitor - but only when explicitly needed. Email does not stay open.

When I finish the task at hand, I reset. I ⌘W all the way down. I take off my headphones, step away from my computer, and shake out my legs. I ask myself: Is there anything that I can do to prevent being interrupted over the next hour? Do I need a break? Do I need to use the bathroom? Respond to email?

If not, I get my mise en place for my next task. If I need a rails server, I start it. I open the code and tests that I’ll be working on along with any docs that I know I'll need.

The goal of a professional programmer is to produce clean, organized code. Software veteran Bob Martin wrote two books on this topic: Clean Code and The Clean Coder. In the latter he says:

The way to go fast, and to keep the deadlines at bay, is to stay clean. Professionals do not succumb to the temptation to create a mess in order to move more quickly. Professionals realize that “quick and dirty” is an oxymoron. Dirty always means slow!

We can avoid pressure by keeping our systems, our code and our design as clean as possible. This does not mean that we spend endless hours polishing code. It simply means that we don’t tolerate messes. We know that messes will slow us down, causing us to miss dates and break commitments. So we do the best work we can and keep our output as clean as we can.

The cleanliness of a workspace is invariably reflected by the product made in it.  TK says: "We're taking great measures at making sure that we have an environment that's very wholesome, very clean, very well organized so that there are no opportunities for food-borne illness."

How would you feel eating food from a filthy kitchen? How can clean code come from a dirty desktop?

If you found this post interesting, you may want to check out others in the Code Like a Chef series: 

Also, I'll be giving a lightning talk on this topic at Windy City Rails next week. 

Want access to more articles like this?  Subscribe now to stay up to date on the latest from Table XI 

August 23, 20122 Comments

Code Like a Chef: Stand Up

This is part three of Code Like a Chef: What Programmers Can Learn from the Best Kitchens in the World. If you want to hear more, come see my lightning talk at Windy City Rails on September 7.

The first step in my quest to code like a chef was to move to a standup desk.

Standing desks are all the rage in tech circles these days. While the health benefits are well documented, that's not why I use one. I have ADHD, and standing improves my productivity and focus.

I used to be envious of a chef's clear separation between work and play. In the kitchen, there is no room for procrastination, no temptation to check email, and no time to read "just one more page of reddit." And at the end of the day, when a chef is nursing his aching muscles on the couch with a cold beer, there's no urge to do a little more work before he goes to bed.

Office workers don't have the same delineation. We spend much of our work time and leisure time in the same place and posture, and it can be difficult to switch gears. I've suffered too much stress in my life because I lacked a good way to tell my brain, "It's time to get back to work" or "You can relax now." A standing desk gives me a clear signal as to what mode I'm in. When I need a break, I take my computer or iPad to the couch. When I'm standing, it's time to get things done.

Chefs, architects, plumbers, carpenters... almost all craftsmen work on their feet - though, I credit Donald Rumsfeld for starting the standing desk movement. Using one most of his career, he got a ton of media attention when, in a memo on enhanced interrogation, he wrote "I stand for 8-10 hours a day. Why is standing limited to four hours?" He was 71 years old at the time.

Detractors of standing desks argue that standing all day is uncomfortable - which is hard to argue against when the practice shows up in discussions on what makes for acceptable torture. A lot of people find standing desks alleviate back and neck pain, but it comes at the cost of your legs and feet. There are ways to mitigate the pain: I stand on a kitchen mat, keep a stool next to my desk, and at the gym I've become intentional about doing leg strengthening exercises. There are enough bathroom breaks and conversations at co-worker's desks to provide natural rest throughout the day.

That said, standing will never be as effortless as sitting. I feel mild discomfort most of the day. I'm constantly shifting my weight from leg to leg - it's impossible to stay stationary. This is a feature, not a bug. The pain and exertion produce a subtle feeling of urgency, focusing my thoughts on what needs to be done now. I literally think better on my feet.

Ultra-marathoner Dean Karnazes says, "Somewhere along the line we seem to have confused comfort with happiness." My best days are rarely the ones in which I'm most comfortable. I've had a few occasions to work a full day in a professional kitchen, and the physical exhaustion I felt after a twelve hour shift produced a euphoric feeling of accomplishment I had not known before.

I don't mean for this to be prescriptive. If you don't struggle with wandering focus and procrastination like I do, or if you have no appetite for physical discomfort, this might not be for you. There's a lot of negativity towards the trend, thanks largely to overbearing evangelism from standing desk hipsters. However, to paraphrase G.K. Chesterton, for most critics, "the standing desk has not been tried and found wanting; it has been found difficult and left untried."

If you're interested in trying, these might be good places to start:

Want to start visualizing your project risks?  Download our free Software Risk Management template

August 15, 20122 Comments

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.

How do you shave seconds?

Keep my hands on the keyboard

In Rails

  • 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.

Other Apps

Want access to more articles like this?  Subscribe now to stay up to date on the latest from Table XI 

August 1, 20121 Comment

Code Like a Chef

Earlier this year, I came back to programming after a long hiatus as Table XI’s sales guy. Though I have been a coder most of my life, this is the first time I've had the job title “software developer.” As I try to discover what it means to be a professional programmer, I’ve found myself taking cues from a seemingly unlikely place: the kitchen.

For four years, I lived with a chef from the sixth best restaurant in the world*. Rene De Leon moved to Chicago in 2005 with no job, no place to stay, and two suitcases—one full of clothes, one full of cookbooks—in hopes of working for Chef Grant Achatz at Alinea. I had just moved to Chicago myself two weeks earlier, and we serendipitously became roommates in an apartment friendly to those with dubious employment status and questionable credit history.

Today, Achatz and Alinea have won just about every culinary award possible, and Rene has been with the company for the better part of six years. After stints at Noma and Cellar Can Roca, currently the number one and two restaurants in the world, he now serves as the Sous Chef at Next, which won the 2012 James Beard Award for best new restaurant in America.

Shortly after we met, I said to Rene, “I’ll buy some groceries if you teach me how to cook.” Thus started my apprenticeship with a world-class chef, and my friendship with the guy who would be the best man at my wedding. My culinary instruction consisted of private lessons over our kitchen island, hundreds of home cooked meals, 2am conversations about Rene’s workday, and visits to Alinea and Next as a guest in the front and back of the house. For seven years, I’ve had a front-row seat to culinary excellence.

The lessons Rene taught me transcend the kitchen. Grant Achatz, Thomas Keller, Feran Adria—these men have more in common with Michael Jordan or Steve Jobs than with the chef at your local Applebees. And though it’s not immediately obvious, coders have more in common with chefs than with desk jockeys like accountants or attorneys.

Coders and chefs are creators. We are craftsmen, drawn to this profession at an early age because we like building things. We thrive on instantaneous feedback and a clear path toward mastery. We work because of passion, not a paycheck, and we’re often found pursuing our craft in the hours off the clock.

We work in industries that are, for better or worse, male dominated, inhabited by strong-willed personalities that would likely wither in a traditional office environment. We operate under tight deadlines to serve finicky customers who have little understanding of our creative process. We go home having seen a tangible product of our labor, and come back the next day to do it a little faster, a little better, a little cleaner.

In the kitchen, I learned how to work clean. I learned the necessity of a prep list, the importance of tool mastery, and the dangers of multitasking. I learned that the best way to build complexity is by layering simplicity. Above all, I learned how to pursue excellence and what it means to be a professional. Over the next several weeks I’ll dive deeper on some of these strategies that I have adopted from the kitchen into my coding practice. As I mature as a software developer, I’ll continue to apply these lessons so that that one day I can say, “I learned how to code like a chef.”

Read more...

* What's that you say? Alinea is the seventh best restaurant in the world? Well, it was 6th... until Rene left.

Want access to more articles like this?  Subscribe now to stay up to date on the latest from Table XI 

GoodFirms Badge