top | item 39172041

(no title)

geitir | 2 years 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.

discuss

order

osigurdson|2 years ago

If code is copied and pasted everywhere that is obviously bad. However, some repeated code is better than none in many cases.

bootsmann|2 years ago

This 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|2 years ago

Even 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.

padjo|2 years ago

No, it just forces you to find an abstraction, not necessarily a good one. Badly designed abstractions can be far worse than repetition.