3 ms·
I think the concept the author is talking around here can be stated more simply: When you refactor software to reduce duplication, you by default are increasin
by derefr 7y ago
I think the concept the author is talking around here can be stated more simply:
When you refactor software to reduce duplication, you by default are increasing coupling.
At the start, you some lines of code that were just sitting in the bodies of two different functions. Now, both of those functions call one shared function. But, in a proper minimal-change refactoring, you didn't change the semantics of the code by doing this. So the shared function is still acting the way that its parents did: as sets of lines sitting in the bodies of functions. There's no circuit breaking or graceful failure there, because there was no circuit breaking or graceful failure in the original, non-refactored code.
Another way to put this is: compression makes data more fragile, in the sense that small numbers of bits can be "depended on" by more bits in compressed data than in uncompressed data. Direct duplication-elimination refactoring is, essentially, just compression.
To actually get robustness, you can't just do this kind of refactoring and then stop; you have to continue on and introduce a stable API to your factored-out function/component/service, with a specified interface. Once you do that, then you cancel out the increase of coupling, because now everything is just coupled to a description of the interface. Then you get the ability to re-use the function/component/service. Until you do that, though, you just have something that is known to work exactly in the use-cases it was extracted from; and which shouldn't be expected to work anywhere else.
- ivanbakel 7y agoI'd agree with you for this post, minus the weird re/usability semantics, but that interpretation goes against the previous parts of this series. If you read Part 1, the argument is largely against even well-architectured versions of re-usability. The author takes issue with all components designed for drop-in future use, believing that each problem requires a tailor-made solution. The re/usability debate seems weirdly entangled with the coupling debate for no good reason. The author believes re-usability means tight coupling, and "usability" means good APIs with loose coupling (which can be re-used...).