Qualities of clean code
Over the years I&#x27;ve seen many more unmaintainable atrocities caused by diligent adherence to these principles than I ever have because of ignorance of them.<p>All the horrid Java libraries that we hated working with 10 years ago were created because of slavish devotion to the single responsibility principle, short methods, DRY, and testability. The absolute worst codebases I&#x27;ve ever seen sprung from an overaggressive concern for extensibility.<p>I do agree with the guiding principle, that when you&#x27;re writing code, it should be written for other people to read and work with. But sometimes that actually <i>does</i> mean that a class should represent an object that does more than one thing, and you shouldn&#x27;t fight it. Sometimes a gritty algorithm really <i>does</i> make the most sense if it&#x27;s laid out as a 40 line function in one place rather than spread across 5 different classes so each part is independently swappable and testable. Sometimes you really <i>don&#x27;t</i> need extensibility, you know that up-front, and building it in just pisses off everyone that ever has to touch your code because now they have to go through five or six &quot;Find implementing classes&quot; dances to find the actual code that runs when your interface methods (of which, of course, there&#x27;s only a single implementation) are called. Don&#x27;t even get me started on abuses of dependency injection when it&#x27;s not necessary...<p>Part of me is glad that these concepts are so commonly discussed, because they really are good things to consider, and can make code much tidier and easier to work with in the best case. But it takes a lot of experience to know when and where you should and shouldn&#x27;t follow these &quot;rules&quot;, and it tends to be much easier to unwind a novice&#x27;s spaghetti code and tidy it up than it is to pick apart a poorly conceived tangle of abstraction and put it back together in a way that makes sense.