Hacker News new | ask | show | jobs
by chacham15 743 days ago
I think it depends on how you deduplicate your code. Creating a DeadlineSettter as illustrated is definitely too much, but creating a function:

  def assert_datetime_in_future(datetime):
    if datetime <= datetime.now():
      raise ValueError(
        “Date must be in the future”)
and then calling that from both places seems fairly reasonable to me.
1 comments

Right? Creating a noun instead of a verb is the real anti-pattern I see here. (Once you have a DeadlineSetter, it's a slippery slope down to ClassInstanceFactoryConfigProxyManager, etc.)