There Are No Easy Problems

Within reason, there are no easy problems. I say “within reason” because there are pretty obvious solutions to some problems, like drinking water when you’re thirsty. But if you back far enough up and attempt to find an abstract solution to “someone is thirsty” you may find that even that problem isn’t as simple as it seems on the face of it.

I came up with a contrived, absurd example but it’s one that I think illustrates the point pretty well. I offer that as a warning because you’ll have to bear with me through what will appear to be really, really obvious deductions in the beginning. I promise that I’ve got a reason for everything I’m about to do.

The Problem

I’ve got a cat and a dog. I really wanted to locate my cat this morning, so we’re examining that problem: “Locate the Cat.” The reason I don’t have to try very hard to locate my dog is that she comes when I call her and that has a limited success rate with my cat (it approaches zero).

The Approach

Obviously, my real-world approach was to check all the spots where she usually naps and then begin disrupting her day with whatever it was I had in mind. But let’s imagine I had to narrow it down starting with the truly absurd.

There are a lot of true things that I can say about the location of my cat, with varying degrees of precision.

She is in this universe. That should be taken as a given.

She’s contained somewhere within the Milky Way galaxy. I know this because I haven’t had to travel very far to see what she’s up to, and interstellar travel isn’t really within the realm of possibility currently. I know she’s in our solar system for very similar reasons.

I can confidently state that my cat is on Earth. We’ve begun to really narrow down the possible search space! Earth is still pretty big, though, so I believe we need even more granularity before we’re able to really locate this animal.

So, in the interest of narrowing it down further: she’s on the North American continent. Still, that’s quite an area to search.

She’s within the United States. Specifically, Minnesota.

In the interest of making my location not too specific, I’ll only say that she’s in my county in Minnesota. Further, in my city within that county! On my property, in my house.

A Smaller Search Space

So we just spent an entire section narrowing the search space down to my house. This is great, now we can really work with this information. It should have been obvious, but for certain kinds of problems, you just never know.

So there are some spaces that we can rule out immediately. My cat doesn’t have access to the upstairs bathroom because it’s honestly no place for a cat to hang out. We’ve got some stuff stored under the sink for cleaning and I know from experience that she’s able to open those doors, so we keep her out of there for her own safety.

She’s also not going to be in the garage. It doesn’t really offer anything for her, and also keeping her out of there drastically minimizes the chances that she’s going to take off on her own. I don’t mean driving the cars or anything, but it’s not something that I’m wholly willing to rule out.

Also, she’s not in the attic, because nothing is in the attic, as far as I know. Plus, you can only access it through the garage and we’ve already squashed that as a potential location.

I also generally keep her out of my home office because she’s prone to touching computer monitors with enough force to knock them over. This is generally my starting location for this quest, as well, so I’m not likely to have to go looking if she somehow ended up in there. She’ll make her presence known.

So we’re left with several rooms, but my cat is pretty small and can hide in weird spaces where humans don’t fit. This means that we’re looking in all sorts of places and bending at strange angles that aren’t especially comfortable for the spine.

With that in mind, there are spaces we’re not going to be checking because there’s no reason to believe a cat would have access to it. Her vertical leap isn’t enough to clear the fridge, for instance, so I’m not going to be checking up there. Plus she’s not able to open a majority of the cabinet and closet doors.

If she manages to close herself in somewhere, she usually starts making noise and pawing at the door so it becomes quickly obvious where she might be. That’s a rare situation, though.

This only leaves every floor or raised surface in my house that is capable of supporting about ten pounds. I’m not going to enumerate those.

There are some areas that she routinely ends up in, though. I usually start the search by checking those spots and I move on from there.

What We’ve Done

We eliminated a truly vast amount of search space! This search has been narrowed to a single house on Earth and all that work was useless!

I intentionally walked through the truly absurd to show how much work you can do on a problem to skirt around the complicated parts and how utterly without value that work can actually be. Once it got narrowed down to “house” I had to introduce all kinds of involved stipulations. That list wasn’t exhaustive, either.

Those stipulations ultimately end up becoming something akin to data validation constraints, if we can drag this closer to the software development world for a moment. Those constraints only hold for my house and my cat – these are not abstract rules.

The last thing I laid out was the general beginning of an algorithm we might be able to implement – maximize our efficiency by checking the common locations and enjoying a nice, amortized performance benefit.

The real work began there as we tried to isolate corner cases and iron out the facts in our system. Even though we were able to eliminate well over 99 percent of the universe, the real work took place in that last, tiny fraction of a percent.

The Point

This was, honestly, a pretty dumb example. I used my cat as a framing device mostly because I wanted to talk about my cat. It was also easier than trying to isolate and describe some kind of software problem because most of us have experience with cats and naturally understand how difficult it can be to get them to show up when you want them.

Even this simple example showed how deeply involved you can become in a trivial problem. Extrapolate that into actual business work or some feature development and it should be obvious how something that isn’t trivial becomes monstrously complicated very quickly. It should also be obvious how something that might appear really simple is going to be hiding some gnarly corner cases more often than not.

This is something that we need to understand, as developers. Partially because we’re going to be the ones solving the problems. Mostly because, at some point or another, we’re going to have to explain the intricacies of the problem to someone else – either for getting their input or providing some kind of estimate.

In those situations, it pays to dig way, way in before you announce that you find the problem easy. There’s usually more to it than you’d think.

Published by Joe

I'm a software developer from Minnesota. I also ride bikes!

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: