WET — Explained with Examples
WET (Write Everything Twice) is an anti-pattern where code is duplicated across multiple locations, the opposite of the DRY principle.
WET stands for Write Everything Twice (sometimes “We Enjoy Typing”). It’s a humorous name for the anti-pattern of code duplication — the exact opposite of DRY. When the same logic appears in multiple places, you have WET code.
Why WET Is Bad
Duplicated code means every bug fix or feature change must be applied in multiple places. Developers miss some copies, leading to inconsistencies. WET code also makes the codebase larger than necessary, increasing build times, review effort, and cognitive load.
Real-World Analogy
Your address book has the same contact written on five different pages. When your friend moves, you must find and update all five entries. Miss one, and you’ll send party invitations to the wrong address. WET is that address book.
Example: WET Code
# WET — validation duplicated three times
class OrderService:
def submit_order(self, items, customer):
if not items:
raise ValueError("Cart is empty")
if not customer:
raise ValueError("Customer required")
# process order...
class PaymentService:
def process_payment(self, customer, amount):
if not customer:
raise ValueError("Customer required")
if amount <= 0:
raise ValueError("Invalid amount")
# process payment...
class ShippingService:
def arrange_shipping(self, address, items):
if not address:
raise ValueError("Address required")
if not items:
raise ValueError("No items to ship")
# arrange shipping...# DRY fix — shared validation
def require(condition, message):
if not condition:
raise ValueError(message)
class OrderService:
def submit_order(self, items, customer):
require(items, "Cart is empty")
require(customer, "Customer required")
class PaymentService:
def process_payment(self, customer, amount):
require(customer, "Customer required")
require(amount > 0, "Invalid amount")Related Terms
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro