DEV Community

Mohammad Jamal Dashtaki
Mohammad Jamal Dashtaki

Posted on

Methods of solving a problem!

It is very important for programmers/developers to be able to find a quick and at the same time optimal and good solutions for a problem/issue, which can be improved by experiencing and seeing programming solutions or best practices. However, there are a series of methods that generally help the programmer to find a quick and optimal solution to any problem, as I said. Basically, the first step to finding the best solution you have to understand and comprehend the problem well, It became a bit philosophical :) You should know comprehending and understanding are different from each other.

When you understand the problem you will find several solutions however when you comprehend the problem you will choose the best solution for it.

To solve a problem, you have to understand and comprehend the problem well. Perhaps the example is that if you understand the problem well, you may have several solutions to it, and when you comprehend it well, you can choose the best solution.

Now, How do we know that we understood it well?!?

The solution that I highly recommend is that you use the Rubber Ducking technique, that is, in order for you to realize that you understand the problem well or not. Let’s explain the problem to your colleague if he understands your problem, it means you understand the problem well and correctly so far. Otherwise, it means that you still need to understand the problem well. In fact, it may be an idea that this step may be very time consuming however it is very important because if you understand and comprehend the problem you can solve it better and faster.

How to understand and comprehend?

  1. Well, now what do we do to understand the issue well? Somebody like Valinda Chan here recommends reading the issue at least three times, here the word "at least" is very important.

  2. Mr. John Sonmez who is the author of the book Soft Skills Here said he believes that if you want to get the best answer you should spend 70% of your time on the stage of understanding the problem. It brings you the importance of this.

  3. The next thing to do is solve the problem with three test data. In fact, you are trying to understand the behavior of your problem with this data, also it will make you pay more attention to Edge Conditions and Corner Conditions.

Finally

You should write your steps that you have solved the problem in the form of pseudo-code, and since you are writing in the steps in pseudo-code, it is much easier to understand at first glance, and besides, you are more involved in logic than code and for instance, you do not think about What should I use for looping now. In the next step, you should convert it to real code and the last step is optimizing and refactoring the code that you have written to get to the minimum code.

Conclusion

Until you don't know what the problem is exactly, you should not jump over it. It is like an algorithm to solve a problem, So you have to move further step by step.

Top comments (0)