How do SOLID principles relate to YAGNI and DRY?

Answer

YAGNI (You Ain't Gonna Need It) and DRY (Don't Repeat Yourself) are complementary principles that must be balanced with SOLID. Tension exists: SOLID (especially OCP) encourages designing extension points even before you need them, which can conflict with YAGNI (only build what's needed now). The resolution is to apply SOLID reactively: when you see a second concrete variation or a second reason to change, that's the signal to introduce an abstraction (the Rule of Three). DRY eliminates duplication, but over-applying it can lead to premature abstractions that violate SRP by combining things that change for different reasons. Martin Fowler's advice: follow DRY when duplication represents the same knowledge; allow duplication when it represents different knowledge that happens to look the same currently.