methodology

Wet Principle

The Wet Principle is a software development concept that stands for 'Write Everything Twice' or 'We Enjoy Typing', advocating for code duplication in certain contexts to avoid premature abstraction. It suggests that developers should wait until they have at least three instances of similar code before refactoring into a shared abstraction, rather than abstracting immediately upon the second occurrence. This approach aims to prevent over-engineering and maintain flexibility by allowing patterns to emerge naturally from actual use cases.

Also known as: Write Everything Twice, We Enjoy Typing, WET, WET code, Duplication over abstraction
🧊Why learn Wet Principle?

Developers should apply the Wet Principle when working on projects where requirements are evolving rapidly or when the cost of premature abstraction (e.g., creating overly complex generic solutions) outweighs the benefits of code reuse. It is particularly useful in agile environments, prototyping phases, or when dealing with uncertain domains, as it helps avoid the pitfalls of speculative generality and keeps code simple and adaptable. By delaying abstraction, teams can ensure that shared code is based on concrete needs rather than hypothetical ones.

Compare Wet Principle

Learning Resources

Related Tools

Alternatives to Wet Principle