6 ms·
No opinion on SOLID with regard to your comment. But DRY is foundational to any code because it forces you to find the right abstraction.
by geitir 3y ago
No opinion on SOLID with regard to your comment. But DRY is foundational to any code because it forces you to find the right abstraction.
- padjo 3y agoNo, it just forces you to find an abstraction, not necessarily a good one. Badly designed abstractions can be far worse than repetition.
- osigurdson 3y agoIf code is copied and pasted everywhere that is obviously bad. However, some repeated code is better than none in many cases.
- bootsmann 3y agoThis is the kind of thinking that leads to unmaintainable AbstractFactoriesFactory classes. Sometimes allowing repeat code is good because two functions might drift away from common functionality in the future which would require a major rework of whatever abstraction you put over them to get them under the same roof.
- osigurdson 3y agoEven in simpler cases it can be problematic. For example, refactoring a tiny bit of repetitive code into a separate function might seem like a good idea. But, over time, things diverge and now additional parameters and branches have to be introduced to support. A small amount of repeated code is optimal.