Technique: Design For Today, Not Tomorrow

The TimeValueOfMoney means that spending later is equivalent to spending less.

Strategy 1:

Strategy 2:

In Strategy 1, we defer complicating the design of the code until the complication actually helps. By paying later, we pay less.

In Strategy 2, we do extra work upfront to prepare for a future that might or might not come to pass. We incur more expense earlier, and our investment in design is not guaranteed to pay off.

The Experience of Future Maintainers

It's worth thinking about how people will feel if they have to modify our code without our assistance.

If we go with Strategy 1, their experience will probably go something like this:

If we go with Strategy 2, they're slightly more likely to experience something like this:

Caveats

We want to defer complication. This does not mean we defer refactoring. Refactoring to make the code simple and clear benefits us today (by making it easy for our coworkers and ourselves to understand the code in its current state).

When working on a team, there is often an advantage to getting architecture in place upfront so work can be parallelized more easily.