Hey hey hey!
Mads here again, bringing you another article to help you improve your coding skills, along with some useful links to make you more productive. Let’s get right into today’s main topic:
How to level up your problem solving skills
As developers, our primary job isn’t to write code.
As counterintuitive as that may sound, our real job is to solve problems. On a broad scale, we’ll be solving problems for users and businesses. On a smaller scale, we’ll be solving concrete coding problems in our day-to-day work. And that’s why learning to solve problems effectively is such an important skill in our developer toolkit.
I think the most important key lies in first breaking each problem into smaller, more manageable components that can be tackled in isolation. This helps ensure we understand each problem and can solve it independently - enhancing our efficiency as we don’t need to think of everything at the same time.
In practice, there’s many ways to go about leveling up your problem solving skills - and one of them is using platforms like edabit.com and leetcode.com. These platforms contain isolated coding challenges you can solve yourself, but you can also view the solutions of others.
Now to be clear, I’m not saying you need to grind leetcode problems every day to “make it” as a developer. But I still think it’s a great way to improve your skills as long as you use a very methodical approach like the one I’m about to share. Below is a list of the steps I use when tackling coding problems like these that I find really help me get better at problem solving:
Fully Understand the Problem: Begin by reading the problem statement thoroughly, making sure you understand exactly what you are trying to do.
Draft an Initial Solution: Start with a simple, naive, and pontentially inefficient approach. Focus on functionality rather than performance or elegance at this stage - just get something working.
Refine Your Approach: Once your basic solution works, think about ways to improve it. Can you make the code easier to understand/read? Can you make it perform better? Remember to make sure your solution still works for any change you make.
Compare and Learn: Once you’re happy with your solution, look at how others have solved the same problem. If your solution matches theirs, great! If not, study their approach to understand what makes it better. Why is the code more readable? What makes their solution simpler than yours?
Reapply and Reinforce: Now this last step is where most people move on to the next problem, but it’s actually the most important: Start over. I’m serious: Delete your code and redo the problem, trying to implement the best solution from memory. This step is crucial in properly enforcing the learning experience you’ve just had. If you skip it, you won’t actually retain any of the information you’ve just worked so hard to pick up!
I personally found this method insanely useful when I was first learning to code, and you can of course use a similar approach when learning from articles or video tutorials. You can also apply very similar steps when working on real-world projects (although you obviously won’t have the exact solution from others to your specific problem).
But in this case, it becomes even more important to properly conceptualize the solution before you start coding. This pre-coding thought process reduces random trial-and-error and leads to a deeper understanding of the problem, helping you to discover potential edge cases early.
Example: Let’s say you need to find the largest number in an array. You might start thinking “I probably need to iterate through the array, keeping track of which number is the largest so far. I’ll have a starting variable set to 0. If I get to a bigger number, I set that as my current maximum and move to the next value”
Sounds reasonable, right? But this is a naive solution - it’ll work for positive numbers. If you went ahead and implemented this right away, you might never think twice about it.
But if you think through it logically, what happens if you pass an array with negative numbers to this function? It’ll report 0 as the largest, which is obviously wrong.
Thinking through these edge cases before writing any code helps to isolate them, and spot potential bugs before they occur. Now we get to think of a better solution, like setting the first number in the array as our starting value - which will make our function work on arrays of both positive and negative numbers 👏
By solving the problem on paper, you also get a much better understanding of what is happening. You avoid trying things at random (as random things are much easier to do directly in code] and instead solve the problem logically. When you’ve got the solution ironed out, writing the actual code for it becomes a breeze. You can even have AI create the code at that point - as long as you properly descibe your solution to it!
So, the takeaway from all of this:
The best way to level up your problem solving skills is through methodical practice, where you spend the extra time and effort to really understand the specific problem + solution to the point where you can recreate it from memory.
When tackling real-world problems, it’s extremely important to solve the problem theoretically before diving into the code. Using pen and paper, sketching out your solution step-by-step helps discover potential issues and prevents nasty bugs that might only surface much later if you jump directly into coding.
I hope these tips helps you level up your problem solving skills - because no matter what the new tools, programming languages or frameworks we’ll be using in the future, the core concept of development will always be centered around solving problems.
Links worth checking out
StyleX. StyleX is a new JavaScript library by Meta used for creating CSS across their many platforms. It’s recently been open sourced, and while I’m not convinced it’s the right approach for smaller projects, it’s definitely interesting and worth considering if you work with major enterprise design systems. Check out this video by t3.gg to learn more about StyleX.
A Chain Reaction. This article by Dan Abramov (one of the primary developers behind React for many years) published this great article on how React turns JSX into something the browser understands. And when broken down like this, it’s actually really simple: Read the full article here.
Raycast. The last tool for this week is a bit different. Raycast is an app launcher / productivity tool for macOS, and it’s been a real gamechanger for me. I’ve been using it for the last year or so and can’t imagine ever going back, with its neat feature set, amazing UX and countless useful extensions to make my life easier. Check out the gorgeous landing page and level up your productivity here.
"As developers, our primary job isn’t to write code.
As counterintuitive as that may sound, our real job is to solve problems. On a broad scale, we’ll be solving problems for users and businesses. On a smaller scale, we’ll be solving concrete coding problems in our day-to-day work. And that’s why learning to solve problems effectively is such an important skill in our developer toolkit."
Totaly agree, because of what use is everything in our toolkit if we can't solve problems with them.
Great read!