Jimmie Houchin wrote:
Dean_Swan@Mitel.COM wrote: [snip]
The other idea that I was trying to get across is that code reuse is a double-edged sword. While it can reduce maintenance effort, and improve the overall quality of a code base, it also makes the codebase more brittle by introducing heavily loaded single points of failure.
This doesn't make sense to me. Increases quality and makes more brittle.
I would think that better quality code... More readable, understandable code... Potentially smaller set of code...
Would lead to more robust and less brittle.
Now as to single point of failure. Uh, maybe. But find and fix and it then should be fixed. And again leading to more robust.
You are both right here taken another dimension into account: control over your code or not.
Inside one component under your control you should avoid code duplication. For me detecting code duplication in principle suggests to create a shareable entity (Class, method, block, Trait (if there)). This said besides the problems tackled by Traits, of course.
But if your component depends on an external component being in a sufficient stable state: this could be a sign to store this external component in exactly this state. Newer versions may or may not work with your component for whatever reason! If it later will be changed, the changed version may be necessary in your system too (both being there made possible e.g. by renaming the old one), to keep newer components - made by you or others - running. Here you end in an extreme case of code duplication!
Examples -------- - You have detected a bug in another component and programmed a workaround. Later a fixing of this bug may break your workaround! Inspite of beeing the fix more 'correct'. - You may not have the time to keep in sync with the improvements of external components you need (to take the positive side of changes of external components, there are more), and the external components used by you are good enough. - From another world: your Java app works with many libs in their versions. After a while you try to update all these libs to their newest state, start your app and something is broken. It may be reasonable just to stop this trial and switch back to all of the older versions...
Regards, Stephan
...