Don’t Repeat Yourself (DRY) is a software development principle, the main aim of which is to reduce repetition of code.
Write Everything Twice (WET) is a cheeky abbreviation to mean the opposite to DRY principle.
So each Software principle has Proc and Cons. Lets discuss about it more.
- One Good thing is
Readability, you can easily follow the code.
Reusabilityis also more important, because same code piece can be reused with little logic change.
Costis more important nowadays, when growing code base, it takes time to test, deploy, storage capacity and so on.
Maintainabilityalso more important, because change of logic in one place applies all over the places.
- You may have to
think a lotbefore implement the logic, because same functionality will be used in any other places.
Over-dried codemay not easily understandable.
Separatorcode for each functionality.
Which one is best?
In terms of deciding DRY or WET bit hard in first place, Personally I feel ugly, When look at the WET code. But if you follow good OOP – Inheritance, Polymorphous, encapsulation and good design patterns, that make you NOT to be WET too much and stay in DRY and shiny.