Blog

Links

Puzzling and coding

posted: January 25, 2020

tl;dr: The similarities and differences between jigsaw puzzles and software development...

Some of my relatives like to do jigsaw puzzles, especially when we get together after traveling long distances. Occasionally we play board games, but jigsaw puzzles have several properties that make them a good fit for these gatherings. Like Minecraft, they are a game of construction, where the aim is to build something together rather than defeating the other players; they encourage cooperation and communication; and a 1000-piece puzzle cannot be completed in one sitting, which encourages different subgroups of people to work on it at different points in time over the course of the family gathering.

I don’t often do puzzles, whether they be jigsaw, crossword, Sudoku, word find, etc., but I do enjoy them. The primary reason I don’t do them more often is that “solving puzzles” is an accurate two-word summary of what I do in my profession. I always have many work-related puzzles on my “To Do” list that I would rather (and probably should) undertake. When I am cajoled into doing a puzzle, and people compliment me on my skills, my response is typically “well I hope I’m good at solving puzzles, it’s what I get paid to do at work.”

In doing a jigsaw puzzle with my family recently, I realized how similar assembling a jigsaw puzzle is to software development:

An assembly of small pieces

A single jigsaw puzzle piece, by itself, doesn’t do much. Neither, in software, does a single expression, statement, or line of code, unless that line of code calls a powerful do_everything() function. The challenge in both is taking these small pieces of functionality and assembling them into a much greater whole. The fit between the pieces is critical: if you try to force a fit that isn’t correct, you’ll just create a bigger problem for yourself in the near future.

Overwhelming at first

A 1000-piece jigsaw puzzle and a large software task can both appear overwhelming at first. When you dump all the pieces from the puzzle box onto the table, you may wonder if you’re ever going to be able to put them all together, and how long it is going to take. The same sensation occurs in software development. One way to counteract this sensation is by the next similarity.

Breaking the overall problem into smaller problems helps

Applying a principle of systems engineering, by breaking the overall problem or system into smaller problems and sub-systems, helps tremendously in both jigsaw puzzles and software. You come up with a big picture plan as to how the overall problem is going to be solved by breaking it into smaller pieces which can be worked on separately and later integrated back into the larger whole. A good way to move forward in a jigsaw puzzle is to find all the edge pieces and start assembling them, and to group other pieces by color or pattern so that smaller portions of the overall puzzle can start to be assembled. These portions of the puzzle can be worked on semi-independently, by multiple people, as long as there is some communication and sharing between them. The same process applies in software development.

Hard to schedule

Large software projects are notoriously difficult to schedule, as are large jigsaw puzzles. It’s very hard to know in advance exactly how long it will take, in time and effort, to reach the end. One reason why, which applies to both, is that solving the overall problem requires solving a large number of smaller problems, each of which involves a small “Aha!” moment of discovery that is difficult to predict.

Walking away helps

I’ve definitely noticed this phenomenon when tackling a tricky problem in both a jigsaw puzzle and software: often it helps to just set the problem aside, go away and do something else, and come back to it later. This break can enforced either externally (stopping for dinnertime) or internally (by going for a walk). When you come back to the problem, your mind will often see things that weren’t apparent before, when you thought you were intensely focused on it. The problem may in fact be that intense focus, which prevented you from seeing other possible solutions. This is also a reason why, when doing a jigsaw puzzle, I don’t spend too much time searching for one final piece to fill in an area: that piece will become more obvious later, when there are fewer pieces available to choose from.

There are some key differences, however:

Doing the easiest parts first is great for puzzles but not software

In software, after the overall problem has been decomposed into smaller problems, I prefer to work on the most challenging subsystems first. If an adequate solution for the most challenging subsystems cannot be found, then the entire software project may be impossible. Tackling the most difficult aspects first also helps with scheduling a software project, as once the difficult tasks are solved the rest of the schedule becomes more predictable. But when doing a jigsaw puzzle, the best strategy is to work on the easiest subsystems, such as the edges and recognizable images, first. This will remove many pieces from consideration for the more difficult subsystems. For a jigsaw puzzle there is no danger of a subsystem not being ultimately solvable, so the approach of doing the easiest subsystems first is a good one.

“Done” is well-defined in jigsaw puzzles but not software

It’s pretty clear when a jigsaw puzzle is done. “Done” is a more nebulous concept in software development. Even if the initial problem statement has been fully realized in code, there is almost always a desire for the software to do more, especially if it is a successful software program. The definition of “done” will often change over the course of a software project, whereas that doesn’t happen in jigsaw puzzles.

Many solutions versus one

For any non-trivial software problem there are a large number of possible solutions, whereas for a jigsaw puzzle there is only one.

Google and Stack Overflow don’t help solve a jigsaw puzzle

These are great tools for getting unstuck when faced with a particular software problem, but they won’t help you find the piece you are searching for in a jigsaw puzzle.