Game Designer & Developer


Game Dev

YAGNI

"Solve only the problems you do have,
not the problems you might have"

xkcd comic 974. Transcript via  https://explainxkcd.com/974:<br>[Cueball sits at a table, eating a meal.]<br>Cueball: Can you pass the salt?<br>[Cueball pauses, a bite of food on his fork, silently.]<br>[Cueball still has fork in mid-air.]<br>Cueball: I said-<br>Off-screen person: I know! I'm developing a system to pass you arbitrary condiments.<br>Cueball: It's been 20 minutes!<br>Off-screen person: It'll save time in the long run!
"I find that when someone's taking time to do something right in the present, they're a perfectionist with no ability to prioritize, whereas when someone took time to do something right in the past, they're a master artisan of great foresight."
Munroe, R. (2011) "The General Problem", xkcd.com/974

In the broader engineering discipline, it is often very easy to fall into the trap of over-engineering a solution. Here are two primary driving reasons I've identified, and hopefully this helps you avoid this trap.

The Desire For a Perfectly Optimised, Ultimately Efficient Solution

This leads to wasting a lot of time when all of that optimisation and efficiency is either completely unneeded for a rarely-run piece of software, or is completely eclipsed by some other, much larger, cost.

When all that's needed is something quick that will only get occasionally used, it doesn't really matter how long it takes to rununless it's dealing with some kind of big data where a single run of the software can take hours, ain't nobody got time for that. If there is some task that needs to be run once a week and it take fifteen minutes to complete, then if you were to spend about four hours trying to shave off five minutes you wouldn't break even until next year. One year to gain the benefit of a 33.333% improvement that only took about half a days work to do. Maybe it would have been better to just deal with those five minutes.

This is a very useful chart for quickly estimating the usefulness of spending time on workflow improvements.

xkcd comic 1205. Transcript via https://explainxkcd.com/1205:<br>[Above the frame is written the following text:]<br>How long can you work on making a routine task more efficient before you're spending more time than you save?<br>(across five years)<br>[The rest of the comic is given in a tabular format. At the top of the table is how often you do the task, with six time increments underneath, and then at the side is written How much time do you shave off at the leftmost part of the page, with 9 lengths of time to the left. The empty fields in the calendar are shaded dark gray.]<br>[The first row is for 1 second, where the table values are 1 day (for 50 per day), 2 hours (for 5 per day), 30 minutes (for daily), 4 minutes (for weekly), 1 minute (for monthly), and 5 seconds (for yearly).]<br>[The second row is for 5 seconds, where the table values are 5 days (for 50 per day), 12 hours (for 5 per day), 2 hours (for daily), 21 minutes (for weekly), 5 minutes (for monthly), and 25 seconds (for yearly).]<br>[The third row is for 30 seconds, where the table values are 4 weeks (for 50 per day), 3 days (for 5 per day), 12 hours (for daily), 2 hours (for weekly), 30 minutes (for monthly), and 2 minutes (for yearly).]<br>[The fourth row is for 1 minute, where the table values are 8 weeks (for 50 per day), 6 days (for 5 per day), 1 day (for daily), 4 hours (for weekly), 1 hour (for monthly), and 5 minutes (for yearly).]<br>[The fifth row is for 5 minutes, where the table values are 9 months (for 50 per day), 4 weeks (for 5 per day), 6 days (for daily), 21 hours (for weekly), 5 hours (for monthly), and 25 minutes (for yearly).]<br>[The sixth row is for 30 minutes, where the table values are greyed out (for 50 per day), 6 months (for 5 per day), 5 weeks (for daily), 5 days (for weekly), 1 day (for monthly), and 2 hours (for yearly).]<br>[The seventh row is for 1 hour, where the table values are greyed out (for 50 per day), 10 months (for 5 per day), 2 months (for daily), 10 days (for weekly), 2 days (for monthly), and 5 hours (for yearly).]<br>[The eighth row is for 6 hours, where the table values are greyed out (for 50 per day, 5 per day and daily), 2 months (for weekly), 2 weeks (for monthly), and 1 day (for yearly).]<br>[The ninth and final row is for 1 day, where the table values are greyed out (for 50 per day, 5 per day, daily and weekly), 8 weeks (for monthly), and 5 days (for yearly).]
"Don't forget the time you spend finding the chart to look up what you save. And the time spent reading this reminder about the time spent. And the time trying to figure out if either of those actually make sense. Remember, every second counts toward your life total, including these right now."
Munroe, R. (2013) "Is It Worth the Time?", xkcd.com/1205

Given similar timeframes, equally unoptimised subsystems can be optimised by comparable ratios not comparable amounts

​When there's a much larger aspect of the system affecting the time, then any savings in one area might be completely unnoticeable. For example: if you are working on a web application, optimising your algorithm that takes a hundred milliseconds is not going to be worth it if the page takes five seconds to load. When optimising anything it is important to focus on what is actually taking the longest not just what is most interesting to optimise. The only way to actually do optimisation properly is with profiling; find what is taking up the most time / memory / bandwidth / etc. and figure out how to reduce it.

Generally speaking: Given similar timeframes, equally unoptimised subsystems can be optimised by comparable ratios not comparable amounts. This means that you can spend a week getting a 20% improvement in your 0.1s algorithm or spend a week getting a 20% improvement in your 5s page load time. Which sounds like a better use of your time?

The Desire For a Perfectly Generalised Solution

Another very common reason for over-engineering is the desire to craft the most perfectly generalised solution ever seen. A single tool that solve any problem, the last system you'll ever need.

As anyone with even the most cursory experience of engineering will know this is not possible. The old saying "A jack of all trades, master of none." applies here as well; The only way to make a tool or system that can handle a wide variety of situations is to compromise on its effectiveness and efficiency in any given situation. If XYZ needs to be done then a tool should be made that does XYZ as best as possible in the given timeframe. That is all that can be done, there's no point in worrying about what problems may be encountered later on, they don't exist now and may never exist. Who knows what could have been done with the time saved by simply doing what needs to be done in the momentsee first image rather than wasting time trying to solve hypothetical scenarios that may never materialise.

This is not to say that engineers should be completely myopic and ignore future problems or not allow for future improvement but just to make sure that we aren't losing sight of what's important: the actual problem in front of us.


And if you don't want to listen to me, then listen to Donald Knuth:

"Premature optimization is the root of all evil"