Someone's manager spent ten years hardcoding years into a constructor using Unix timestamps. Instead of just calling currentYear() like a normal human being, they wrote a beautiful cascade of if-statements checking if the current timestamp exceeded specific values for 2027, 2025, and 2024.
The refactored version on the right? One line. One beautiful, elegant line that does what it should've done from day one. But hey, at least the manager kept themselves employed with annual "maintenance" updates, right? Job security through incompetence is a valid strategy.
Fun fact: Those Unix timestamps represent October 1st of each year at midnight ET. So not only was this approach terrible, but it would also break every October 1st until someone manually added another else-if. Chef's kiss. 💋
AI
AWS
Agile
Algorithms
Android
Apple
Bash
C++