Is 'Clean Code' a Myth? A Modern Software Engineering Inquiry into Evolving Principles
The modern software engineering community is grappling with a fundamental question: Is ‘clean code’ a myth we tell ourselves? Kevin Henny and Daniel Turos North explored this topic, delving into its historical context and contemporary relevance. They identified multiple ‘vectors’ for the concept: Robert C. Martin’s influential 2008 book ‘Clean Code,’ Kent Beck’s recent ‘Tidy First’ initiative, and predating both, Richard Gabriel’s concept of ‘habitable code’ from the 1990s, characterized by comfort and confidence in making changes. Historical analysis, championed by Henny, revealed the term ‘clean code’ was in the air as early as the 1970s, notably in Kernighan and Plauger’s ‘The Elements of Programming Style,’ and later used by Ron Jeffries and Martin Fowler in discussions of refactoring as hygiene. This suggests a distinction between ‘Clean Code’ (capitalized, sometimes perceived as dogmatic practices) and ‘clean code’ (a more general, suggestive metaphor for code quality that focuses on the developer’s experience and relationship with the codebase).
The conversation highlighted how software development’s evolution impacts the applicability of ‘Clean Code’ principles. While some advice, like establishing clear boundaries and good naming conventions, remains timeless, other prescriptions—such as breaking code into numerous small, scattered pieces—have ‘aged like milk.’ This particular advice, relevant in the late 90s for teams compartmentalized by function (e.g., UI, database), becomes an administrative burden for today’s full-stack developers. Instead, the focus shifts to ‘locality of behavior’ and a ‘single goal principle,’ ensuring all components related to a specific objective are close at hand. The discussion emphasized that ‘small’ code should refer to reduced cognitive load, not just line count. Ultimately, drawing from the Theory of Constraints, the ‘cleanliness’ of code should be a function of its purpose: to facilitate sustainable, fast, and effective software delivery. Over-cleaning can be an opportunity cost, while under-cleaning acts as a constraint. Therefore, cleanliness is not a fixed, dogmatic ideal, but a relational and contextual judgment aimed at enhancing habitability and developer joy.