Tips, Tricks and Insights into Solving Programming Problems

Drew Coleman
6 min readJun 19, 2019
Photo by Émile Perron on Unsplash

When I first started learning to program, I was taught many things, but I was never taught how to solve problems and because of this I struggled a lot in the beginning. A lack of confidence is a sure-fire way of killing a passion. Fortunately for myself I am damn stubborn and carried on regardless, and eventually I stumbled my way through enough programming problems that my confidence started to grow, and I got a real sense of knowing what I was doing.

Fast forward a few years and I am now working professionally as a game developer having built up a lot of experience solving programming problems. If you would have asked me when I first began if I believed I would ever be getting paid to make video games I would have told you no, yet here I am.

I feel that some of the knowledge and experience I have now could of gone a long way into helping me get to where I wanted to be a lot quicker. Which is why I want to write this article providing some insights and practical tips to help you along your way to becoming a game developer.

Understand the Problem

The first thing you need to do which seems obvious is making sure you understand what the problem is asking you to do. Anyone who has taken a maths test knows that half the battle is figuring out what the question is asking you to do. This is no different. You should read over the problem several times and write down everything you think is important, even the tiniest of details and don’t start doing anything else until you are confident you know what you are doing.

Breaking Things Down

In order to be able to solve a problem you must be able analyse the problem and break it down into smaller steps. Even after breaking it down you might have to continue to break down those smaller steps into even smaller steps, again and again until you have a set of tasks that are small enough to solve on their own. These tasks will be small and simple enough that you can program them into a computer.

Don’t Just Start Coding

It’s tempting to just start coding and work out the solution as you go along. This is typically a bad idea. If you don’t fully understand the problem or haven’t figured out how to solve it yet, then what’s the point of trying to code. You just complicate things. Now you have to think about two things, how to solve the problem, and how to do so in a way that the computer understands. That’s why it’s a lot easier if you separate the two, figure out what you need to do first, then figure out how to get the computer to do it.

Programming is about Iteration

I used to be in the mindset that you plan, write your code, and then you are done. Realistically coding requires multiple iterations. You write code to solve a problem, you debug it along the way when it doesn’t execute. Once you have something working you test it and realise it breaks half a dozen times and that after all this it runs terribly and needs to be optimised.

You might write several different solutions to your problem before you come up with a solution which meets all the requirements. It’s unrealistic that anyone writes final code to solve a problem first time, there will always be some changes that can be made.

Problem Solving Demands Hardship

I can tell you that I spent a lot of my initial time learning how to program by googling how to solve problems. When given a task if I didn’t immediately know the answer, I would google it. I would have an answer that I might understand but I never reached that conclusion myself and that’s crucial to becoming a good developer. You can’t get good at solving problems if you never actually solve problems.

That’s not say that you shouldn’t ever look at another person’s work. Only you can really judge when you have spent enough time working on a problem and just need to see the answer. When you have already exhausted all possible avenues, and even if you have solved the problem it’s good to look at how other peoples have done it. A great way to get better at programming is to learn how other people code. You just have to must make sure you are not neglecting learning to be a better problem solver.

Be Realistic

Be aware of what you want to do, but also be aware of your limitations. You wouldn’t try and run a marathon if you can’t even run a mile, yet I have seen people trying to make games without having any experience writing code.

When it comes to problem solving the key is to give yourself a realistic problem to solve. Apply what you already know whilst pushing yourself a little out of your comfort zone. I’ve seen a lot of people fail because they gave up before their skills matched the ambition of what they wanted to achieve.

Getting Unstuck

If you have the knowledge but are still stuck, that is you don’t understand how to solve the problem and how to break it down into smaller steps then a good technique explained in Thinking Like a Programmer is to reduce the problem. Try to solve a simpler yet relevant problem and hope that by solving a simpler version of the problem you gain insight into how to solve the original.

Simplifying the problem can involve adding or removing constraints to the problem in order to make it easier. Eventually you’ll have to solve the original problem but by doing this you are making progress that will hopefully help get you unstuck.

Coding is about Trade-offs

There is never a perfect solution. I will repeat this again, there is never a perfect solution. We will always have to make some trade-off as there are always some limitations that we are working against. If it’s a game we might be limited to running it at 60fps, we might be working on hardware that is less powerful or has limited battery life. We might simply not have enough time to solve the problem.

When writing code, we should be aware of the requirements our code needs to meet and be able to analyse what we have written to know why it might be bad. If we had little time then our code might be a little less readable, or we might be allocating too much memory, or for performance we had to make the code less reusable.

Regardless of the situation it’s important to know that the code you will write will be bad in some way, whether its reusable, performance, readability, or something else.

There is More Than One Way to Solve a Problem

Finally, there is always going to be more than one way to solve a problem, some of them might be better than your current solution in some ways other solutions might be worst. Either way you are given a lot of freedom as a developer to tackle problems in anyway you want based on all the knowledge and skills you have gained.

I hope these tips, tricks and insights have proven useful in helping anyone having difficulties solving programming problems. I realise there is no code in this article, and that some of you might want to see some of the points I have mentioned put into practice so rest assured I will go into more detail in future posts.

Until then feel free to message me @gamedevunboxed if you have any questions or check out more posts at www.gamedevunboxed.com :)

--

--

Drew Coleman

Game developer writing articles about: game development and programming.