# Premature DRY abstraction assuming
# uniform rules, limiting entity- # specific changes. class DeadlineSetter: def __init__(self, entity_type): self.entity_type = entity_type
def set_deadline(self, deadline): if deadline <= datetime.now(): raise ValueError( “Date must be in the future”)
task = DeadlineSetter(“task”) task.set_deadline( datetime(2024, 3, 12)) payment = DeadlineSetter(“payment”) payment.set_deadline( datetime(2024, 3, 18)) | # Repetitive but allows for clear, # entity-specific logic and future # changes. def set_task_deadline(task_deadline): if task_deadline <= datetime.now(): raise ValueError( “Date must be in the future”)
def set_payment_deadline(
payment_deadline): if payment_deadline <= datetime.now(): raise ValueError( “Date must be in the future”)
set_task_deadline( datetime(2024, 3, 12)) set_payment_deadline( datetime(2024, 3, 18)) |