I write software. And nothing brings me greater pleasure or satisfaction in my work than being able to create an elegant solution.
The word “elegant” has a specific meaning in technical fields, and it’s high praise indeed. It refers to getting the best possible outcome with the least possible effort. High value, low mess.
Let me try to give you the feeling of it, without geeking out too badly: Suppose my team is trying to figure out how to achieve a goal, and we’ve been talking through several alternatives. “Well, if we rip out this code over here and rewrite it and then create a new section over here and we connect the two, but then we’ll have to modify how this piece operates…” Everyone jumps in with ideas, alternatives, what-if’s, and the “solution” keeps getting bigger and messier and more unwieldy, and every time someone pipes up, I’m calculating another 4 hours of work, 3 days of work, 2 weeks of work. The whole thing is making me wish I’d had the good sense to be a mendicant nun. There’s a pause, and someone says, “What if we just rewrote these few lines of code over here?” Silence while several developers ponder this new idea, trying to find the flaw. The Gotcha. Each person remarks, “Yeah… that would work.” Another moment of silence. Is this too good to be true? “That,” I say, “is an elegant solution.”
Elegant solutions are effective, efficient, beautiful, and, once achieved, feel effortless. They have a sense of rightness about them. Elegant software transcends code and becomes poetry.
(I know a solution is elegant when I keep stopping through the day to sneak a peek at that bit of code because it’s just so darn pretty.)
When I have a thorny problem in my code, I often face the temptation to rush towards an inelegant solution. Duct tape and paperclips, whatever gets it done, “it’s good enough for now,” we’ll refactor later. It’s a constant and powerful temptation, and it’s the reason there’s so much awful code in the world. When I give in to the temptation, I blame it on external forces: I don’t have enough time; we don’t have enough money; I don’t know how to do this. But writing bad code is always, at core, procrastination; and procrastination is, at core, a lack of attention. An inability to remain present with discomfort (in this case, the discomfort of code that doesn’t function properly) and maintain focus, remain engaged, until you find a good solution.
I’m starting to believe kludgy code is symptom not of business constraints but of a constrained soul.
In my own case this is certainly true. In Zen practice, we say, “Wash your bowl.” When you’re done eating, you simply wash your bowl. You do what needs to be done, right now. Then you do the next thing. Each task completed with full attention. When I bring this approach into my software, I write good software.
In creating the algorithm of my own life, sometimes I’ve been sloppy, careless, inattentive. I’ve used lack of knowledge, and of ability, as excuses rather than as prompts to grow. But I’ve been working on slowing down, focusing, taking the time and energy to learn what I need to learn. Working with teachers, therapists, mentors; studying, practicing, experimenting. Thinking things through. Taking action.
So, in a sense, I’m refactoring my life this year. Taking the things that are clearly not working, rewriting them, and running the algorithm again to see if it performs better. And I don’t just want to repair minor bugs; I want to rethink the entire structure and work towards that clean, simple, elegant solution.
In pursuing elegance, I’m starting with three simple principles that have been useful to me recently:
- Cultivate attention
- Release obstacles
- Minimize debt
That’s it. Once upon a time I would have created a rococo edifice of goals, rules, and schedules. It would have all sounded very intellectual and impressive, and it would have lasted about five weeks before the whole thing collapsed under its own weight.
Instead, I’ve learned to simplify, and these are the three guidelines that will guide me through this year of refactoring. Cultivating attention permeates every aspect of life; it’s really the uber-principle, since every human capacity, in my experience, is grounded in our capacity for attention (or lack thereof). “Release obstacles” was taught to me by Greg Nardi, a unique and powerful yoga teacher, and that phrase has been profoundly life-changing for me. And minimizing debt, in my book, is about so much more than money; it’s about the debts we create every day with thoughtless promises, with procrastination, with any action that tries to pay tomorrow for what we want today.
So there you have it. Elegance in a nutshell, and my strategy for pursuing it. The ideas sound lovely; the execution will, I’m sure, be quite a bit messier. But you don’t arrive at elegance without traipsing through a whole lot of muck. So let’s start traipsing.