Design Patterns

Code Smells: Static References to Time

So you need to do some time-specific calculations in your application. It’s related to the current time, so you do the usual thing, and new up a DateTime object: $now = new DateTime(); Seems innocuous, right? But you quickly run into some pretty nasty problems: Your code is now very difficult to test reliably. To […]