4 ms·
I'm not really sure I know what you mean by "compression in the guise of abstraction". Re-usable code is a great way to isolate a discrete piece of logic / func
by no_wizard 3y ago
I'm not really sure I know what you mean by "compression in the guise of abstraction". Re-usable code is a great way to isolate a discrete piece of logic / functionality to test and use in a repeatable manner. A sharable module is the simplest and often smallest form of abstraction.
- fauigerzigerk 3y agoReusing a function C in functions A and B makes A and B dependent on C. If the definition of C changes, the definitions of A and B also change. So this is more than reusing some lines of code. It's a statement that you want A and B to change automatically whenever C changes. If this dependency is introduced purely out of a desire to reuse the lines of code that make up C, then I'm calling it compression. In my view, this is a bad and misleading form of abstraction if you can call it that at all.
- rewmie 3y ago> Reusing a function C in functions A and B makes A and B dependent on C. If the definition of C changes, the definitions of A and B also change. To pile onto this example, in some cases the mastermind behind these blind deduplication changes doesn't notice that the somewhat similar code blocks reside in entirely different modules. Refactoring these code blocks into a shared function ends up introducing a build time dependency where previously there was none, and as a result at best your project takes longer to build because independent modules are now directly dependent or at worsr you just introduced cyclic dependencies.
- camjohnson26 3y agoUnrelated modules often superficially look like each other at a point in time, I think that’s what the parent is referring to. An inexperienced developer will see this and think “I need to remove this duplication”. But then as the modules diverge from each other over time you end up with a giant complex interface that would be better off as 2 separate modules. So deduplicating unnecessarily compresses the code without adding anything to code quality.
- fauigerzigerk 3y agoUnrelated modules often superficially look like each other at a point in time, I think that’s what the parent is referring to. Yes, exactly.