Code should be clean… right?

Given a choice between clean code and not-clean code, the decision seems obvious. After all, clean code is compact, neat, and professional. It’s the kind of code that teachers and professors would probably gush over. It’s the kind of code that most developers have probably been taught.

But is coding clean the best way to code?

According to Dan Abramov, maybe not. Abramov posted this article at the beginning of the year, and it was quickly shared and debated fiercely in the Rocket Slack channels.

Abramov’s point is that many developers are guilty of going overboard in the pursuit of perfectly clean code. Oftentimes the amount of energy put into tidying code is wasted down the line, when other developers go back in and have to chip apart tight blocks of code to modify it. In a case like this, the cleanliness of the code serves only the satisfaction of the developer who wrote it. A messier version of the same code, on the other hand, is more utilitarian and offers greater longevity.

Naturally, we decided to bring this debate to our Ship It podcast. In this episode, we pit ultra-clean code against less-than-clean code with a discussion between four of our senior engineers: Matt Merrill, Simon Ingeson, Brandon Aaskov, and Dave Oeflke.

All four break down their opinions when it comes to best practices of coding, including when is it good to code clean and when is it good to code messy.

One thing they can all agree on is that although there are best practices, there are no hard and fast rules when it comes to coding clean. This stuff is subjective, which makes discussion like this all the more valuable.

Listen to the whole conversation here.