It’s a Phase
Obsessing with “clean code” and removing duplication is a phase many of us go through. When we don’t feel confident in our code, it is tempting to attach our sense of self-worth and professional pride to something that can be measured. A set of strict lint rules, a naming schema, a file structure, a lack of duplication.
You can’t automate removing duplication, but it does get easier with practice. You can usually tell whether there’s less or more of it after every change. As a result, removing duplication feels like improving some objective metric about the code. Worse, it messes with people’s sense of identity: “I’m the kind of person who writes clean code”. It’s as powerful as any sort of self-deception.
Once we learn how to create abstractions, it is tempting to get high on that ability, and pull abstractions out of thin air whenever we see repetitive code. After a few years of coding, we see repetition everywhere — and abstracting is our new superpower. If someone tells us that abstraction is a virtue, we’ll eat it. And we’ll start judging other people for not worshipping “cleanliness”.
I see now that my “refactoring” was a disaster in two ways:
Firstly, I didn’t talk to the person who wrote it. I rewrote the code and checked it in without their input. Even if it was an improvement (which I don’t believe anymore), this is a terrible way to go about it. A healthy engineering team is constantly building trust. Rewriting your teammate’s code without a discussion is a huge blow to your ability to effectively collaborate on a codebase together.
Secondly, nothing is free. My code traded the ability to change requirements for reduced duplication, and it was not a good trade. For example, we later needed many special cases and behaviors for different handles on different shapes. My abstraction would have to become several times more convoluted to afford that, whereas with the original “messy” version such changes stayed easy as cake.
Am I saying that you should write “dirty” code? No. I suggest to think deeply about what you mean when you say “clean” or “dirty”. Do you get a feeling of revolt? Righteousness? Beauty? Elegance? How sure are you that you can name the concrete engineering outcomes corresponding to those qualities? How exactly do they affect the way the code is written and modified?
I sure didn’t think deeply about any of those things. I thought a lot about how the code looked — but not about how it evolved with a team of squishy humans.
Coding is a journey. Think how far you came from your first line of code to where you are now. I reckon it was a joy to see for the first time how extracting a function or refactoring a class can make convoluted code simple. If you find pride in your craft, it is tempting to pursue cleanliness in code. Do it for a while.
But don’t stop there. Don’t be a clean code zealot. Clean code is not a goal. It’s an attempt to make some sense out of the immense complexity of systems we’re dealing with. It’s a defense mechanism when you’re not yet sure how a change would affect the codebase but you need guidance in a sea of unknows.
Let clean code guide you. Then let it go.
Improve your performance online with the Ryte suite
Monitor, analyze and optimize the key elements of your website efficiently with one tool.
Smooth jazz seemed like it would dominate forever.But then, everything changed.In the early 2000’s Arbitron, the firm that measures audiences, introduced a new technology,The Purple People Eater —I’m sorry I meant to say the “Portable People Meter.”It’s this little beeper — people believe it killed smooth jazz.PPM, which is still in use today – is an electronic beeper that captures audio tones masked inthe signal of radio broadcasts. Basically, it picks up audience listenership automatically.It replaced a decades-long practice of using paper diary entries to measure audiences.“People would write down for a week what they listened to and they would turn it in. Very easy for people to do.”“It went from that to,what we want to ask you to do is wear this on your belt all dayand we want you to do this for a year.”But it often didn’t work with smooth jazz.The format’s soft, ambient sound didn’t allow for the signal to be consistently maskedin the music without being discernable to listeners – if the signal wasn’t embedded,the beeper just couldn’t register it.Polling site Fivethirtyeight tracked the number of six large-market smooth jazz stationsbefore and after PPM – in each instance they either changed formats or shutdown entirely.But it might not have been all PPM’s fault“I think it’s a reflection of what our economy did.Our station went off the air when everything crashed.”Smooth jazz radio was music for ordinary, everyday people trying to get through theirday stress-free.It certainly never cared about critics during its solid 20 year run, and unlikestraight-ahead jazz, it didn’t care so much about challenging the listener either.And it’s why from the 1960s to the ’90sanything written about the music looked like this:But dig deep into smooth jazz’s history and you’ll find some really exciting music.“There was an album Herbie Hancock did call the “New Standard.”“Oh man that was good.I’d come off there talking about that.”“I was like, Oh this is what this is why I’m doing what I’m doing.”Or go even further back to Grover Washington Jr.’s “Winelight.”“And just listen to it as you’re cooking dinner or something.”“It’s just chill, man. And it’ll give you a feeling for why people fell in love with this music.For such a long time.”
Just under ten years ago, the International Commission on the Measurement of Economic Performance and Social Progress issued its report, Mismeasuring Our Lives: Why GDP Doesn’t Add Up.The title summed it up: GDP is not a good measure of wellbeing. What we measure affects what we do, and if we measure the wrong thing, we will do the wrong thing. If we focus only on material wellbeing – on, say, the production of goods, rather than on health, education, and the environment – we become distorted in the same way that these measures are distorted; we become more materialistic... The OECD has constructed a Better Life Index, containing a range of metrics that better reflect what constitutes and leads to wellbeing... The new report highlights several topics, like trust and insecurity, which had been only briefly addressed by Mismeasuring Our Lives, and explores several others, like inequality and sustainability, more deeply... Better indicators would have revealed the highly negative and possibly long-lasting effects of the deep post-2008 downturn on productivity and wellbeing, in which case policymakers might not have been so enamored of austerity, which lowered fiscal deficits, but reduced national wealth, properly measured, even more... Political outcomes in the United States and many other countries in recent years have reflected the state of insecurity in which many ordinary citizens live, and to which GDP pays scant attention. A range of policies focused narrowly on GDP and fiscal prudence has fueled this insecurity. Consider the effects of pension “reforms” that force individuals to bear more risk, or of labor-market “reforms” that, in the name of boosting “flexibility,” weaken workers’ bargaining position by giving employers more freedom to fire them, leading in turn to lower wages and more insecurity. Better metrics would, at the minimum, weigh these costs against the benefits.. Spurred on by Scotland, a small group of countries has now formed the Wellbeing Economy Alliance. The hope is that governments putting wellbeing at the center of their agenda will redirect their budgets accordingly. For example, a New Zealand government focused on wellbeing would direct more of its attention and resources to childhood poverty... Better metrics would also become an important diagnostic tool, helping countries both identify problems before matters spiral out of control and select the right tools to address them. Had the US, for example, focused more on health, rather than just on GDP, the decline in life expectancy among those without a college education, and especially among those in America’s deindustrialized regions, would have been apparent years ago... Likewise, metrics of equality of opportunity have only recently exposed the hypocrisy of America’s claim to be a land of opportunity: Yes, anyone can get ahead, so long as they are born of rich, white parents. The data reveal that the US is riddled with so-called inequality traps: Those born at the bottom are likely to remain there. If we are to eliminate these inequality traps, we first have to know that they exist, and then ascertain what creates and sustains them... A little more than a quarter-century ago, US President Bill Clinton ran on a platform of “putting people first.” It is remarkable how difficult it is to do that, even in a democracy. Corporate and other special interests always seek to ensure that their interests come first. The massive US tax cut enacted by the Trump administration at this time last year is an example, par excellence. Ordinary people – the dwindling but still vast middle class – must bear a tax increase, and millions will lose health insurance, in order to finance a tax cut for billionaires and corporations.If we want to put people first, we have to know what matters to them, what improves their wellbeing, and how we can supply more of whatever that is. The Beyond GDP measurement agenda will continue to play a critical role in helping us achieve these crucial goals.