Problem Solving as a Developer

22 December 2022

4 min read

Agile software development team
Photo by Parabol | The Agile Meeting Toolbox on Unsplash

Everyone is different and how one developer solves problems compared to someone else might not be the same. The ability to think creatively and analytically and breaking down problems into smaller parts and strong problem-solving skills are essential to becoming a successful developer. 

There are seven different concepts to solving coding problems they can all be used when tackling a problem, they include: identify, research, pseudocode, test, implement, reflect and repeat.  

A structured approach will not only help you deliver a solution more quickly but also means that you always have a plan when people ask. 

Identify the problem

Before writing code, we need to understand what needs to be achieved. This can be done by thinking about the context of the problem, the issue we are trying to solve and why we are doing this.  

Know exactly what is being asked. Most hard problems are hard because you don’t understand the problem at hand. Write it down. Draw a diagram. Try explaining it to someone else in simple terms.  

Can the problem be broken down into sub-problems? It's much easier resolving smaller problems that will eventually lead to solving the main problem. 

Research

Google is a developer's best friend and researching what other people have done, searching for answers will help a lot. Its highly likely that someone had the same (or relatively the same) problem as you and managed to solve it.  

I’m not saying that a person should copy and paste from StackOverflow and the problem is solved. Understanding the code is vital to understanding a possible solution to the problem and copying won’t help with your learning journey. Nobody should blindly paste code into their company’s codebase without knowing what it does. There are some exceptions to this I think, like complex regular expressions. 

Another reason to doing the research first is to see whether there are any libraries or packages that you can use in your solution. Why re-invent the wheel? 

Write pseudocode

Focus on logic and use high-level pseudocode. We need to get a better understanding of the inputs, the process, and the desired outputs for the problem without getting bogged down on programming language syntax.  

For example, we want to look for the maximum value in a collection. We could do something like this: 

Given a collection of numbers 

Set max to zero 

For every number in the numbers collection 

If number is greater than max 

set max to number 

Return max 

Test

The test-driven development (TDD) method involves writing tests first, then using those tests to guide the design and development of your software. 

The TDD approach called red (write the failing test first), green (write code to make the test pass), refactor (simplify and optimize the code), a framework that developers use to build a test suite, write implementation code, and optimize their codebase in short development cycles. 

When building functionality, you can use tests to guide your logic by starting with the simplest functionality first. Breaking down a problem into smaller, more manageable pieces facilitates problem solving. 

Implement

Write code to make all your tests pass in the least amount of time possible. “Done is better than perfect.”  

A big problem is solved by taking small steps, and if you spend all your time perfecting the small steps, the bigger problem will take a long time to solve. 

Reflect and improve

Improve readability and refactor. It is easier for the reader to understand the intent of the code when it is readable. This includes proper indentation, writing comments so that your future self and other developers can understand your code and using good naming conventions.

Repeat

And lastly, practice. The fastest way to learn a foreign language is to have conversations with native speakers and just like anything in life, no one gets good at programming and solving programming problems without practice. To overcome challenges, you need to spend quite a bit of time practicing and pushing yourself.

Back
buy me a coffee