Get Professional

Problem Solving Skills: 5 Strategies for Any Programmer

6 Jul , 2016  

Hey everybody, I thought I’d spend a little time on a favourite topic of mine – problem solving.

As programmers, solving problems is what we do when we get down to work. The more problem solving skills and strategies we have, the better we’ll be.

The problem might be “how can I tell if this string contains a valid e-mail address”, or “what’s the best way to process more transactions per second to solve this latency problem our customers keep complaining about?”.

They’re different classes of problem, but what I’ve found over the years is that I can improve the quality of my solutions by applying some tactics to my problem solving, and not just waiting for something to pop into my head!

So I’m going to cover a few of my favorites right here.

Problem solving strategies for programmers

Problem solving skill 1: Make it smaller

This is the most fundamental approach to problem solving, and it should be the very first thing we do.

Back in the day, it was called ‘decomposition’ which sounds kind of nasty.

But this is good! This is the process of breaking a problem into lots of tiny sub-problems until we end up with a list of trivial problems that are easy to solve.

Let’s clarify with an example.

We’ll imagine – for the sake of fun – that you’re going to build your very own personal home accounting system: it’s going to produce a ledger report, graph income and outgoings over time, and help you prepare your tax return.

That sounds like a lot! But let’s start breaking this down into smaller problems.

First smaller problem – the application will need to get it’s data from somewhere, and an export from your bank is the perfect place to start.

One of the options your bank will probably provide is a CSV export of your transactions. CSV stands for Comma Separated Values, and part of your CSV file might look like this:

2016-08-02, 10:23:30, "-10.45", "7-11 BROADWAY 22034","+2241.34"

Meaning – on August 2nd 2016 (10:23AM) you spend $10.45 at the 7-11 on Broadway, leaving $2241.34 in you account.

So we’ll break our problem – getting the data – down some more –

  • We need to open the CSV file
  • Read each record in the file
  • Break each record into individual fields
  • Load the fields into a database record
  • Close the CSV file

Breaking a problem down into small, discrete problems that can be solved one at a time is how you’d build an entire application.

But what if you don’t know what the right solution is?

Download this list of 17 things you can do to improve your problem solving.

Problem solving skill 2: The 3 x 3 method

problem solving skills

Often we treat solutions to problems the same way we treat lost house keys – as soon as we find them, we stop looking!

But problem solving is different to lost keys – we might not come up with the best solution first off.

Actually, the first solution we come up with is often the most obvious – nothing wrong with that – but once the obvious solution is out of the way, we can start thinking of new and different things.

Often these turn out to be better solutions than the first thing that occurred to us.

So one actionable step you can take when you sit down to solve a problem is not to stop until you come up with three different solutions.

This can be surprisingly hard to do – the resistance to keep on working on a problem after you’ve solved it once is powerful.

But if you do, you’ll encounter unexpected problem solving creativity.

But this is the 3×3 method, right?

So your second actionable step can be thinking up three things that could go wrong with each of your three solutions.

Boy, now doesn’t that sound like fun?

I think one of the hardest things in the world is to sit down and think really hard about what might be wrong with our wonderful ideas.

But it’s worth it!

Once you do that, you’ll not only have thought through each of the solutions thoroughly, you might realise that some of the problems you thought up can be solved by combining your solutions into super-solutions, more robust and creative than your first idea!

Download this list of 17 things you can do to improve your problem solving.

Problem solving skill 3: Know your solutions.

“There’s nothing new under the sun, boy.”

So I was told by an old analyst at my first job, squinting at me between his grey, bushy eyebrows.

I didn’t believe it then, and I don’t now (even though my eyebrows are getting just a little grey now).

But he did have a point.

A lot of the problems we come across in day-to-day programming life are tricky – we wouldn’t be paid to solve them otherwise – but they’ve come up in the past and been solved.

And then those solutions have been improved and improved until we’ve got something as close as possible to a perfect solution for that problem.

And then some people started documenting those solutions.

Some of you will be saying to yourself at this point – “hmm, sounds like design patterns…” and you’d be right.

But keep reading!

A couple years after the Gang of Four published their Design Patterns book (a compendium of standard solutions to tricky problems) Design Pattern Mania took over the industry for a while.

After the inevitable backlash design patterns lost a lot of their shine.

But I think they’re still a great tool to bring to problem solving – if we use them judiciously.

By that I mean recognising that they’re designed for complicated problems and it’s pointless to use them for everyday problems.

Normally, we’d only turn to a design pattern when our regular solutions come up short.

If you want a good grounding in design patters, I heartily recommend the Head First Design Patterns book. It’s seriously one of the best books I’ve encountered for getting up to speed quickly on a subject (and it was put together by the incredible Kathy Sierra, one of the superstars of developer education).

Download this list of 17 things you can do to improve your problem solving.

Problem solving skill 4: Break taboos

So I totally acknowledge this is about to get weird. I’m sorry about that, but stick with me 🙂

I have a hypothetical problem for you.

Bad news: you’re locked in a cement cell with eight other people.

There’s a lead pipe set in the concrete floor, six inches of the pipe is below floor level and six inches of it is above floor level. There’s a ping pong ball at the bottom of the pipe, and the pipe is slightly wider than the ball.

The cell guard won’t let you and your eight friends out until you give him the undamaged pingpong ball.

You have a hammer, a chopstick and a shoelace to help you retrieve the pingpong ball.

What you gonna do? A solution is below, but spend some time coming up with your own before you scroll down to it.

problem solving problem

Common solutions include: splitting the chopstick in two and attempting to tweezer the ball out. Others mount a frontal assault on the concrete floor with the hammer and attempt to excavate the pipe from the floor.

How about another solution? (This is where it gets weird).

There’s you plus eight other people in that room. Sooner or later someone’s going to have to pee. And you know, once one person goes, everybody will want to go.

And where will they do that?

How about the pipe? And once everyone starts peeing in the pipe, that ball’s going to float on out, undamaged.

I know, gross.

But the thing is, very few people discover that solution (if you’re one of them – well done! I didn’t get it).

Why don’t many people think of it? It’s elegant, doesn’t require any of the tools you were given (I mean “misdirected with”) and happily gets everyone out of the place before it really gets stinky.

The reason most people don’t find that solution is that it involves a taboo – namely a bunch of people using their pee constructively!

I found something interesting happened once I had cleared that taboo – I though of lots of new solutions to the problem that involved breaking other taboos.

But that’s not the kind of taboo we deal with in our professional lives (or I hope not!). But there are other kinds of taboos:

“We don’t use Perl here.”

“You must always/never use foreign-key constraints.”

“Javascript is evil/our saviour.”

There are lots in the programming world. The question is, once we break the taboo, what new solutions do we start to see?

Download this list of 17 things you can do to improve your problem solving.

Problem solving skill 5: Know your problems

Finally, our last problem solving tactic isn’t about solving problems so much, as recognising them.

Sometimes when I was presented with a problem I just had to dive in and fix it straight away . Usually because it was my code that was causing the problem and I was just plain embarrassed 🙂

But sometimes it can be hard to separate a problem from a symptom.

A symptom, for example, was when, as a junior developer, my code one day started showing out of date data to a customer. This was a big deal – the data was used by our customer to make important business decisions, and if they lost confidence in the data, they’d lose confidence in us.

I was getting the customer data from a cache used by our application. We used a cache because it was expensive and slow to query the data. It looked like the cache was out of date and had to be refreshed.

Just refresh the cache before you fetch the data. Why do I have to explain this to you?” This was my boss, who was terrified we were going to lose some valuable business.

I hung up the phone and that’s what I did. Clearly, we had to make sure that particular report had the most up-to-date information in it. Always.

Then a funny thing happened.

Other areas of the application started occasionally showing out of date data too. ‘Refresh the cache’ became a mantra and our cache quickly became useless as the application spent all its time querying and re-querying the database.

Our technical lead, who’d designed the caching system in the first place*, put a stop to this and investigated what was going on in the cache.

It turned out that the code that triggered automatic cache updates had a subtle, time-zone relate bug in it.

Once that was fixed, we put an end to forced cache refreshes, and everybody was happy.

So I think we have two actionable steps –

  1. Have the gumption to respect your own decisions and analysis when someone senior is yelling at you.
  2. Think hard about how the problem you’ve seen occurred, and whether you’re fixing it, or just putting a band-aid over it.


The main point here is that there are lots of ways to approach a problem, and that circumstances will determine which you choose.

I think the most important thing to take away from this is that you should trust your ability to understand problems and come up with create, effective solutions.

Happy problem-solving!

PS – Bonus strategy! Read up on ‘Rubber Ducking‘. It’s fast, simple and it works 🙂

Download this list of 17 things you can do to improve your problem solving.


3 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *