“Yak shaving” (or “shaving a yak”) is a term coined by Carlin Vieri, an MIT Ph.D., in the ’90s after watching an episode of “The Ren & Stimpy Show.”
But what is yak shaving?
Yak shaving refers to a task, that leads you to perform another related task and so on, and so on — all distracting you from your original goal. This is sometimes called “going down the rabbit hole.”
Let’s look at this real-world example.
You want to bake an apple pie, so you head to the kitchen.
In the hallway, you notice some paint chipping on the wall.
So you walk to the hardware store for some paint.
On the way, you pass a bakery and stop in for a cupcake.
While eating the cupcake, you feel a pain in your mouth. It’s that cavity that you’ve been putting off.
You pick up your phone to call the dentist to make an appointment, but you see a notification from your friend Cher, who’s having a party.
You don’t want to show up empty-handed, so you stop for a bottle of wine. …
You get the picture. What ever happened to that apple pie?
In coding, it might go something like this.
You set out to fix a bug in a line of code.
But before you do, you refactor it into its own function.
And why isn’t this function in its own file?
In fact, the entire file should be broken up into a main function and multiple utility functions. …
Whatever happened to fixing the original bug? Sure, all of these other things are good on their own, but they are distractions.
How can you stay focused on the original task? Fix the bug in one pull request. If you truly need to make all of these other enhancements, do them in separate pull requests. Never fix a bug and refactor in the same pull request.
You may even decide that these enhancements are distracting you from your immediate goal of shipping a feature. In this case, there is nothing wrong with addressing them in a tech debt sprint.
Please don’t misconstrue what I’m trying to say in this article. Refactoring is a good thing when dirty code is involved. (Not letting dirty code into the code repository in the first place would have been better, but I digress. Ack! Yak!) Refactoring has a time and a place, but refactoring in the middle of a simple bug fix is neither the time, nor the place.
In short: Stay focused on the task at hand, and don’t shave that yak!
More on the origin of the term “yak shaving”
In a follow-up email exchange on the origin of the term, Carl Vieri shared this:
For me, “yak shaving” should be things that are related to your primary objective, not just distractions. … [for example,] where tools are out of date, or there are other minor hurdles that take you on a path away from your primary task, but that can be traced back to that task.
As for “Ren & Stimpy,” I used to play hockey late on Tuesday nights. I would have dinner at midnight Tuesdays and watch TV, and I saw the “Yak Shaving Day” episode. I thought it was so odd, that later when I was struggling to overnight a document (getting permission from an admin, setting up a DHL account, getting a PO, all that nonsense), I told my officemate I was yak shaving. Over the next few weeks/months, I tried to get folks around the lab to use the term, and Jeremy Brown really liked it. He used it in his GSB post a couple of years after I left the lab.