Problem solving is in my opinion, the best asset in a developer, the ability to not only code, but also design solutions gives a differentiating element among the developer population.
Be proficient in a framework, an specific programming language or technology, matters, that is really important. But problem solving should be the complement of this knowledge.
Solutions should be independent of the language. Depending on the programming language you might need to re-write an algorithm or instead use an already built function with the same behavior. But the main knowledge should be in how we can design an optimal solution for every problem.
The brain is a muscle and a muscle should be train
If a soccer player pretend to have a good performance during the weekend match, he should train during the week in order to be physically and mentally ready for the match. Same case for developers.
We can not always only search on internet to find the solution of a given problem. Developers should be able to: identify, design a solution and solve those kind of problems, then technically you can have resources online or even with your team, but the ability to create a solution should be in every developer.
Is it really needed?
Well, from my experience, I have been only in one technical interview where I was asked to code and solve 3 problems during the session. So we can say that, to be hired, it will depend on the interviewers; but in the real work, in daily basis developers face logical problems, so that is better to be ready. Then, my opinion and answer to the question is: yes, definitely.
A well defined process
Not all the problems are similar, but for all of them we can split the process in 3 basic steps:
Identify the problem: We can not fix/solve something that we don't know. First step must be always understand the problem, be able to describe it by yourself. A good exercise is draw it on paper, try to visualize by your own, how the code will look, identify the inputs/outputs/rules/etc. that the problem involves. Then, try to describe it, if you are working with someone else, try to explain the problem, if he/she is able to understand it, you might have the enough knowledge and understanding regarding the problem.
Design multiple solutions: Not regarding code itself, more about pseudo code, algorithms. Design only one solution and try to make it work for the issue could be dangerous if the nature of the algorithm/approach that we implement is not the ideal for that specific problem. Here is the importance of before to code, think... and think well.
Choose and implement the optimal solution: Well, this is the last step (ideally) where we have few options of solutions and we need "only" choose one and implement. What is the importance to choose the ideal solution? Two words: code once.
Code should be always the last step of problem solving, after identify the issue, think and design solutions, finally we came to code.
Then, if code is the final step, testing is not needed? In my opinion, the very first "testing stage" is during the second step, where we design the solution, but every stage must be tested, avoiding assumptions.
Let's say that we want to fix a ranking function for students based on scores and some other rules. While we start to design the solution (mostly on paper), all the possibles scenarios should be considered, scores, rules, exceptions to the rules, data types, error handling, data size, etc. And not only sorting funtions.
Sometimes we find temporal solutions where we know that for some specific (valid) scenario, our code will fail, but if we try to cover it too, the code could be more complex. That's the real importance of this final step, be consent that all scenarios might happen on production (even the ones that you don't imagine), then, if you already know that something could break your code, don't choose that solution, invest more time in second step, design an optimal solution and only after that, code it.
Time is the most valuable resource for a developer
Usually, as developers we don't have enough time and we try to code it faster. The truth also is that, if you code something that is not good enough you will need to invest (more) time when the "fix" come back after sometime with a new bug.
As one of the best programming quotes mentions: Think twice (or even more), code once.
Practice as much as you can
Maybe in the resume wont be as valuable as the master in some framework, but believe me, during working it is really helpful.
How can I getting started?
In order to improve this skill, there are many sites (Online Programming Judges) that provide a set of problems for all the levels, depending on the site you will have the chance to work with different programming language to focus only on solve the problems and not about learn a new specific language.
These are the ones that I used to visit:
Start with the basics, all of us started with A+B before to come with data structures, string process, encryption, etc, avoid frustration and do strong progress, no matter if it is slow when it was learned well.
This is my first post in dev.to, I hope you had liked it...
We're in this together
Level up every day