(2) Inheritance, abstract classes, and the like (as well as principles of generic programming) can all be used to create very clean and maintainable code. (Check out my company's PawLIB library for one such example...although I might be biased?)
However, you are correct - those same tools can just as easily be used to make spaghetti. It would be hard to write down all the rules about that here, but there are definitely more than just "DRY".
(3) The other issue that DRY can introduce into the code is a plethora of instruction-cache misses, which occur virtually every time you are calling the 'jump' instruction under the hood (function calls, etc.) We can't avoid jumps altogether - we'll need a lot of them in good code - but either having too many jumps or having them in the wrong places can tank your program's performance.
(4) At least in C and C++, macros are an underappreciated tool at our disposal. (Yes, I hear readers screaming in agony, but hear me out.) If a piece of code is heavily used, but either performance-critical, or otherwise not well suited to isolation into a separate function, macros work well for preventing unnecessary duplication, without introducing instruction cache misses (the cost is increased compiler time).
Of course, again, macros can be abused to create spaghetti code.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Good article! Four thoughts:
(1) Dry spaghetti is still spaghetti.
(2) Inheritance, abstract classes, and the like (as well as principles of generic programming) can all be used to create very clean and maintainable code. (Check out my company's PawLIB library for one such example...although I might be biased?)
However, you are correct - those same tools can just as easily be used to make spaghetti. It would be hard to write down all the rules about that here, but there are definitely more than just "DRY".
(3) The other issue that DRY can introduce into the code is a plethora of instruction-cache misses, which occur virtually every time you are calling the 'jump' instruction under the hood (function calls, etc.) We can't avoid jumps altogether - we'll need a lot of them in good code - but either having too many jumps or having them in the wrong places can tank your program's performance.
(4) At least in C and C++, macros are an underappreciated tool at our disposal. (Yes, I hear readers screaming in agony, but hear me out.) If a piece of code is heavily used, but either performance-critical, or otherwise not well suited to isolation into a separate function, macros work well for preventing unnecessary duplication, without introducing instruction cache misses (the cost is increased compiler time).
Of course, again, macros can be abused to create spaghetti code.