Ask HN: Code Reuse or Just Plain Well-written Code?
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.
[+] [-] msg|18 years ago|reply
I find I often write something as helper functions for a GUI or library, then break it out when someone else needs to call it. It's definitely better from my perspective to leave it sitting in the old class until you come up with something more urgent than scenarios for how someone might use such a library someday.
Coding standards are also extremely important to ensure that someone will be able to look at your code and use it without deciding to rewrite it from scratch.
[+] [-] schtog|18 years ago|reply
Seems logical as well, you reuse your hammers and screwdrivers, not your house.