
“You’ll never convince me that reusable code isn’t mostly a menace”-Knuth, 2008 - ohjeez
http://www.informit.com/articles/article.aspx?p=1193856
======
dexwiz
I really agree with the quote, especially after spending some time in a huge
enterprise codebase (1mil+ files). Writing reusable code usually means writing
an abstraction layer. However, if you always write an abstraction layer, you
will end up with a ton of abstract code with only one concrete implementation.
Abstract code is harder to read and modify, so you do pay a cost when it comes
to maintenance. Also depending on the language you may pay a runtime cost
also. So if your goal is always to write reusable code from the start, you pay
an investment cost that may never show any returns.

This idea pairs well with another Knuth quote regarding premature optimization
being being evil [1]. Code reusability is a form of optimization of developer
time. Writing reusable code with only one implementation is like optimizing a
function that does not impact performance. You think you are doing something
good because programmer dogma says its good, but in the end its not.

Here is another related article that does a great job talking about
maintainable software, and some of the contradictory advice you will hear
about it [2]. But the main point is that code is transient. We tend to write
code with the idea that it may run in production undisturbed for decades, but
that is not the case. Refactors are common, and most people will do a better
job rewriting code from scratch than trying to modify your code. So do them a
favor, and make it easily replaceable instead of easily modifiable, mostly
because your opinion of what is easy to modify is just as subjective as your
opinion of what is good code.

[1]
[http://wiki.c2.com/?PrematureOptimization](http://wiki.c2.com/?PrematureOptimization)
[2] [https://programmingisterrible.com/post/139222674273/write-
co...](https://programmingisterrible.com/post/139222674273/write-code-that-is-
easy-to-delete-not-easy-to)

~~~
Gibbon1
I always thought the idiom of 'reusable code' is in deep conflict with
'ruthless refactoring'

I've come down to keep your interfaces and paradigms stable, architecture flat
and couplings low.

