News for hackers. Stuff that matters.
Re:Don't DRY Your Code Prematurely by LorenPechtel on Sunday June 02, 2024 @01:39PM (#40555878)
My thought here is that they're focusing on the wrong thing.

Yes, we have repetitive date-checking logic, but we don't want lay a trap for the future. Not sure what language this is in so I'll use C#:

EnsureDateInFuture(DateTime Time) { if (Time <= DateTime.Now()) throw new Exception("Date must be in the future"); }

One check for the future, one copy of the error message, not locked in.

There are no comments on this comment yet.