3 ms·
The alternative to DRY is... Repeating yourself. Which is fine once or thrice but not too many times. Second alternative is code generation, which brings its o
by AstralStorm 7y ago
The alternative to DRY is... Repeating yourself. Which is fine once or thrice but not too many times.
Second alternative is code generation, which brings its own problems, but is relatively clean. (Custom build systems are a pain.) You have to keep balance to not turn the code into some DSL for example.
Then you can also do macros, especially if the language has a decent enough support. (In C++ the equivalent is not C macros but templates and RAII pattern.)
And finally, you do not need to move code out to necessarily reuse it all the time, or even make it public. Things that work together best stay together, and strengthen encapsulation.