What if messy code could be fun, not frustrating?
Tidying with Marie Kondo is Netflix’s latest hit. The company rarely shares the viewership data, but its popularity can be gauged from donations to thrift stores that have registered a huge uptick since the show debuted (as Marie advocates discarding things that don’t “spark joy”). I can’t say I am a fan, but I love Marie’s demeanour and simple, repeatable tips for tidying your space.
One thing that struck me is how Ms. Kondo, unlike most of us, isn’t disgusted by mess. In fact, she giddily says on the show that she loves it. Of course, you can say one ought to if they’re in the business of tidying up living spaces. However, I feel the reason is more innocent than that—one that I found very relatable.
As a programmer, I love working with a messy codebase.
That might sound baffling. After all, clean code is the holy-grail of software development. If you are a programmer who cares about the craft, you learn early on that you are not writing for the machine, but for another programmer who will read and maintain it. Awful code receives nothing but collective disgust.
My response, too, wasn’t any different. Recently, however, my opinion—and they way I approach mess—has changed. I am not troubled by messy code; in fact, I actively pursue it.
I’ll give an example to illustrate the “why.” If I am working on an incredibly convoluted PHP code, my initial response would be a sense of frustration. Gradually, my frustration will grow and will create a feeling of strong dissatisfaction. All us must have faced a situation like that at some point of their career. But, what happens when I start improving (refactoring) the code? Things start to change. A sense of achievement takes the place of discontentment. I start feeling motivated to introduce more changes that improve the code quality.
Mess doesn’t have to be source of immense frustration. You don’t have to curse the person who left spaghetti code for you to work on. Rather, you need to think how things can be made better. That mindset would make the work far more enjoyable. I love mess when I am empowered enough to make improvements and can be reasonably sure that it won’t go back to its ugly state.
I admit there are limits to this. In some organizations it’ll be difficult to get a buy-in for refactoring code, because for the management, it’s eating into the precious development time. Some codebases are far too fragile, complex, and inscrutable to attempt any change. However, most of the times, mess is a solvable problem—and a fun, rewarding one at that. All it takes is some initiative.