How do I solve complex problems?
Before writing a line of code (if the solution requires you to code), you will need to have a step-by-step approach that would help you…
As time passed, I realized that software engineering is purely problem-solving. The ability to solve problems distinguishes good and great software developers.
Throughout the past months, I have been approached by friends in the industry asking what my problem-solving process is and how I seem to always know where to look when asked for help. So, I decided to write this article to share how I solve the different tasks or problems I have at hand.
What is problem-solving? — You may ask; We can find various fancy definitions explaining what problem-solving actually implies. Some would define it as referring to psychology, computer science, cognitive science, or even logic, which is not wrong. Yet, in all different areas, it can be applied; it simply boils down to the ability of an individual or a group to solve given problems regardless of their complexity.
Problem-solving consists of using generic or ad hoc methods in an orderly manner to find solutions to difficulties. (Wikipedia)
Solving a problem
Most people approach problems differently; some use technique x, others technique y. Of course, some approaches are more efficient than others, but I don’t think there is a predefined method of solving a problem. I personally use a process that I have seen some of my favorite engineers use, proving to get the job done.
Enough talking; LOL; here is how I solve problems regardless of their complexity:
1. Understand the problem
Problems are like puzzles; we need first to see a complete picture before attempting to solve it. The first step to solving any problem is understanding what you are being asked to accomplish.
🚩 ”we cannot do anything without understanding.”
A common mistake that I would often make when assigned a task was to jump straight to my code editor and start writing the solution without knowing the final picture. Eventually, I would figure it out and solve the task, but I was very inefficient as I would ask the right questions late because I didn’t have a complete picture of what I was asked to do.
Clearly, before starting, we should seek to comprehend what is that we need to achieve; for this, we need to:
Ask the right questions
Write down the problem as you understood
Validate your understanding of the problem
2. Break down into smaller chunks
After learning what the problem we have at hand is, we now should be to divide it into smaller and achievable subtasks. Using the puzzle analogy, if you have a big puzzle, you clearly have a picture of how it will look like once you complete but to quickly solve it, ideally, you would group the pieces that fulfill a section into small chunks. The same should apply to any problem you are solving.
Before writing a line of code (if the solution requires you to code), you will need to have a step-by-step approach that would help you have a solution for your problem puzzle. This can be challenging, but you can break things down and have a clear path to your solution if you understand the problem.
To get better at this, you will need to practice writing down; this can be seen as you are writing pseudocode that solves your problem by listing all the steps and indicating checkpoints that should be met before moving forward to the next stage.
🚩 “Divide and conquer.”
3. Relook the solution
Like in a code review process, in this step, if I have someone else available, I usually ask for a second opinion on my assumptions so I see if the next person at least can understand what it is that I am solving. Yet if I don’t have a second pair of eyes, I simply reiterate each step as if it was a new problem to be 100% sure of the solution I have in mind.
As this is the last step, I usually take more time catching possible issues and going back to the drawing board to adjust my initial assumptions.
🚩 The aim is to “write twice and code once.”
Only after relooking at my chunks; I do start applying what I have written down, always keeping in mind that this is not the absolute solution and that it can constantly be improved.
After all, solving problems is a skill that requires time to be developed (I am still working towards improving myself to become a better problem solver). Yet, I realized that the more problems you solve, the better you will become at providing a solution to issues that come your way, regardless of their complexity.
This doesn’t only apply to the software engineering profession but to all others. We are all solving problems one way or the other, so we all should find a process that works to better solve the problems we encounter daily.
Let’s keep on hacking 🙂.