Ask HN: Code Reuse or Just Plain Well-written Code?
https://news.ycombinator.com/item?id=218072Someone said (or maybe it's not attributed to anyone) "great programmers reuse code". Even if you change that to great programmers "write reusable code" it's still hard to see how it is true in practice, since both great and non-great programmers write reusable code. But I guess it takes a great programmer to do it well, so maybe that was the gist of the saying.
In my experience the only kind of reusable code that is immediately helpful is a library of functions. Beyond that it seems like the effort required to integrate say, a pre-made javascript widget into an application you are creating, and then understand the widget code well enough to make it work perfectly with the application, is about the same amount of time it would take to write it yourself.
That is not to say I have no interest in a pre-made widget, and in fact not being as good of a widget-maker (in the time I have available for the project) as the widget developer apparently is, it seems like a very appealing idea to reuse their code. But reusing it will often result in something less than optimal.
So it seems to me that something approaching an ideal solution in cases like these is that code should be quasi-reusable, or perhaps it should break into discrete parts that could be reused. More importantly, it should be possible to readily understand the code so that some part of it or all of it, could be integrated into the application you are creating, making changes to it that are not klugey but make sense with how the code is intended to be used.
This is of course an old topic, but I'm curious to hear what people think is currently the best way to approach this ages-old problem.