software = science + art + people
2012-11-26
In the 1950s, researchers at Johns Hopkins conducted some very troubling experiments. They caught wild rats and squeezed them in their hands until they stopped struggling, teaching them that nothing they did would let them escape the crushing grip of their human captors. Then they dropped the rats in a bucket of water and watched them swim.
Now, wild rats are superb swimmers. On average, rats that had not received the squeeze treatment lasted around 60 hours in the bucket before they gave up from exhaustion and allowed themselves to drown. One unsqueezed rat swam for 81 hours.
The average squeezed rat sank after 30 minutes.
In the 1960s and 1970s, Martin Seligman became interested in this phenomenon — he called it “learned helplessness” — and he was able to trigger similar “giving up” behavior in dogs and other animals. He theorized that human depression is a reaction to learned helplessness in the face of emotional or mental challenges against which we repeatedly make zero headway. Other researchers showed that not only did squeezed rats stop swimming faster, they also lost some of their spatial reasoning and memory abilities.
Hopefully, this experiment disturbs you on many levels. Even putting aside ethical questions, the implications are enough to make your skin crawl. At least one pundit has connected the rat experiment with waterboarding at Guantanamo. Probably there are interesting insights about addiction, interpersonal relationships, bullying, politics, and many other social issues to be gleaned as well.
I see interesting connections to tech debt.
Working In Debt
If you’ve ever worked on a truly yucky codebase — one littered with #ifdefs, massive and arcane functions, and undocumented and surprising logic; one having organizational principles known only to long-gone creators; one possessing far too few unit or regression tests; one smack dab in the middle of the strategic path of the company — then you know what it’s like to be squeezed like a rat in a researcher’s gloved fist.
You have to fix bugs, but every change causes you to grit your teeth and cross ayour fingers and toes, because you have no confidence that the fix won’t break something else. Squeeze.
You know your mental model is incomplete — in fact, the mental model of everybody on the team is insufficient, even in the aggregate. You avoid dark corners of the codebase; here there be dragons. Squeeze.
You desperately want to refactor — but you know the Keepers of the Budget and Schedule™ will never consent to let you rewrite to nearly the degree that you need. And worse, you know that you really can’t start this effort anyway, because the risk of destabilizing things is just too high. (Remember, you don’t have enough unit or regression tests.) Squeeze.
In that kind of codebase, you can come to feel like every breath of creativity, every spark of excitement, every hope that you can make a difference, is being squeezed right out of you.
Although this discouraging perspective is not unfamiliar to me, I firmly believe that humans are smarter than rats.
And that matters.
The Power of Habit
I’ve previously written about my Grandma paying off her mortgage after many years of diligent effort. This was the harvest of a good habit, applied consistently.
With financial and tech debt, after big setbacks there is a temptation to throw up our hands. “What’s the use?” we want to say. “Nothing we do will make any difference.” We sympathize with the guy who, saddled with a million dollar medical expense, tells himself that living within his means is irrelevant, and goes on a shopping spree.
This is the equivalent of the squeezed rats giving up after 30 minutes in the bucket. We have to be smarter.
If you are working in a codebase with deep tech debt, you have to be disciplined about good habits. Write unit tests. Name your functions well. Make things as modular as you can. Chip away. And away. And away.
If you are saying: “That’s not going to erode the big debts — at least, not fast enough to make any difference!” — then I hear you. Believe me. But:
Over the long haul, thinking about best practice, talking about it, and then doing it, day in and day out, really does pay off. As Lao Tse (supposedly) observed:
“Watch your thoughts; they become words. Watch your words; they become actions. Watch your actions; they become habit. Watch your habits; they become character. Watch your character; it becomes your destiny.”
Although I feel for every engineer struggling in a yucky codebase, I don’t have much sympathy for those who use the struggle as an excuse for bad habits.
The Power of Imagination
Besides having a capacity to consciously choose our habits, human beings also surpass rats in their ability to find creative solutions to problems. Remember Kirk and the Kobiyashi Maru?
[youtube=http://youtu.be/bDg674aS-F4]
Brainstorm with like-minded engineers, and see what ideas emerge. Here are a few tried-and-true options to ponder:
Importantly, imagination isn’t just a problem-solving tool; independent of answering the “how”, it also gives us a “why” to our efforts. In the rat experiment, all the subjects saw during their time in the bucket was a metal wall, with no conceivable egress. The learned helplessness that defeated the squeezed rats was mostly a death of imagination. When Shackleton climbed into a lifeboat to attempt the 1500 km crossing to South Georgia Island, his goal was just as invisible. But he survived because he could imagine climbing out again, his journey behind him. And he kept imagining that, day after day, until his keel hit pebbles.
So…
Never underestimate the power of habit. Never underestimate the power of imagination.
And keep swimming. :-)
Action Item
Find a good coding habit that you've neglected, and re-commit to do it with discipline and vision.
Comments-
-
-
-
-
-
-
-
-
-
dougbert, 2012-11-26:
good model to follow. dead rat here
Daniel, 2012-11-26:
Aw, c'mon, Doug! Maybe a bedraggled and waterlogged rat. You were still cracking jokes last time I saw you coding, so you must be alive and kickin'... :-)
LisaAn, 2012-11-27:
I have often wondered why teams don't take the approach of grabbing a few backlog items and stuffing them in the cracks, so to speak, to chip away at the technical debt. Perhaps we are overwhelmed by the task.
Daniel, 2012-11-27:
One of the more insidious consequences of always stretching to fit in "just one more feature," late in the game, is that all ability to mine nooks and crannies in the schedule is lost. We spend every last cent on new bells and whistles, instead of on cleaning the workshop. Sigh...
dougbert, 2012-11-28:
alright, alright - good reality check - thanks, but I definitely felt the pattern you are describing. We are having an issue with a grandson who is "helpless" if you will due to a parent who is a corrections officer, and this pattern applies here too. Hope is key to working in a "tight" environment anywhere.
Trev, 2012-12-05:
A professional kitchen needs to be cleaned each and every night, with an occasional deep clean where one pulls out all of the equipment and cleans everywhere. If its not done, Health and Safety will eventually come by close it all down. The suggested approach reminds me of Old Man Yu (http://ancientchinesestories.com/2009/04/04/ancient-chinese-stories-the-tale-of-old-man-yu-gong-and-the-mountain/). So, the question is how does one combine Eastern long-term thinking with the Western reliance on quarterly earnings?
Daniel, 2012-12-10:
I think all of us that have been educated in Western universities need a crash course in gestalt, system thinking. And then we need regular reminders, until we understand that analysis (in the sense of its original meaning, of reducing everything to smaller units) is not the be-all, end-all outcome of serious thought.
Ian Nate, 2012-12-28:
Profound and applicable. Love this post. Reminds me of Frank Abignale, Sr., played by the indubitable Christopher Walken, from "Catch Me If You Can": http://youtu.be/51lFmdChOA0
Daniel, 2012-12-29:
Ian: I had not made that connection, but it is a *great* one. Thanks for pointing it out!
Earned Pragmatism « Codecraft, 2013-01-18:
[...] this type of “architect” tend to be rife with tech debt, with no roadmap or process to haul the team up and out. Where there is no vision, the people [...]