Every developer has heard the advice: "Don't Repeat Yourself."
But what if following that principle too aggressively makes your code harder to maintain?
Sometimes, duplicating a few lines of code is better than creating an abstraction that complicates everything.
This is where DRY vs WET becomes interesting.
What Is DRY Code?
DRY (Don't Repeat Yourself) is a software development principle that encourages developers to avoid duplicating knowledge or business logic across a codebase.
The idea is simple: Every piece of knowledge should have a single, authoritative representation in a system.
Consider this C# example:
public decimal CalculateProductTax ( decimal price ) { return price * 0.075m ; }
public decimal CalculateServiceTax ( decimal price ) { return price * 0.075m ; }
Enter fullscreen mode
Exit fullscreen mode
Both methods implement the same tax calculation.
If the tax rate changes, you must update both methods.…