How to Get Unstuck on Coding Problems

Subscribe to my newsletter and never miss my upcoming articles

Got stuck on a coding problem? It's alright. Every developer experience every time we try to solve problems that we haven't encountered yet whether it's a new technology we're using, trying out a different approach, or debugging our old (spaghetti) code.

In this article, I will provide you ways and tips to help you get unstuck on the problem you have been solving for hours already. Let's dive right in!

1. Clarify

pexels-pixabay-356079.jpg

So you've been tackling this task for hours now, and you still have questions on the back of your mind about what the actual goal of the task is. This will happen a lot during the development phase, do not worry about getting it all figured out. You will find more questions to ask when you start the development.

Go ahead and Clarify.

It never hurts anyone to clarify what the goals of the tasks are. Ask for edge cases, ask for what the ticket is trying to solve. This way you will have a better understanding of what you need to do and you will gain insights and ideas on how will you tackle it.

Questions that you can use

  • What the tasks are trying to solve? Is it bug fixing, performance optimization, or integration?
  • What are the requirements?
  • What technology to be used, what APIs are available?

2 . Break down the problem

pexels-breakingpic-3243.jpg

Now that you have gotten a grasp of the task that you are trying to solve, let us try to break it down.

For example, you are tasked to create a login page with design, development, and integration with the backend API endpoint. How can we break this down?

Steps

  1. Make specifications for the login. This includes the user interface and user experience for the login page you are designing. What will be the login form validations, errors, and success messages? You can use pen and paper to brainstorm and create wireframes or use design applications such as Figma and Adobe XD.
  2. Develop your design Now that you already have the UI design and the functional specifications, develop your application. It would be easier for you to develop when you do not have to think of "what to develop" during the development phase because you already designed it beforehand. All you have to do is look at the specifications and create it.

Let's break down the development even more. We'll list the things we need to develop.

  1. Login Page Container
  2. Login Form
  3. Login Text Fields
  4. Login Button
  5. Login API Integration
  6. Login edge cases (validations, error messages, success messages)

See, you have more control and visibility on what is needed to be done rather than only having the big task to create login page.

3. Take a break

pexels-kaboompics-com-6398.jpg

This may seem counter-intuitive but you should take a break! You have been solving that problem for 4 hours now and not going anywhere, give yourself 30 minutes or more to rest and get your mind off from coding.

The reasoning for this is that the human mind has two modes of thinking which are Diffused Mode and Focused Mode as discussed here by Barbara Oakley.

image.png

In focused mode, we are exerting a lot of brain effort to the problem that we are solving, and our brain is locking on to a certain path of solutions as you can see in the image above. This is useful when you want to concentrate on trying to solve the problem with the solution that you have in your mind.

While in diffused mode, our brain is much more relaxed and more creative. This the mode when we are daydreaming or doing nothing in particular like when we are eating, showering, and walking. In this mode, your mind will be open to other paths of solutions and can look at the bigger picture.

4. Go back to the documentation

pexels-pixabay-357514.jpg

Since you have an idea of what to do, but still get stuck because you have no idea of how to make something work. You have to go back to your language or framework's documentation.

In my opinion, developers mostly try and solve the problem by looking at the documentation only when they need it to confirm what the parameters of the function are, or how to implement a certain thing.

However, by reading or even skimming at the documentation first, we can have an idea of what tools we have available for that programming language and framework before we start. That way, we'll have better implementation for certain things because we know that certain tools can handle it better than our workarounds.'

Additionally, we'll gain more knowledge on the framework's developers intended implementation and principles of why the tool was created and we may implement it in our projects.

5. Pair with another developer

pexels-christina-morillo-1181274.jpg

We already have searched the internet, Stackoverflow, Medium, Dev.to, and Hashnode but we still haven't understood how to solve it. If you have a co-worker, classmate, or a developer friend, I suggest that you pair with them to solve the problem.

It is essential that we have other eyes looking at our code because sometimes, we are locked into certain solutions for our coding problems and unable to see other possible solutions. It may be a semicolon you have missed, a wrong variable type you haven't noticed, a function that you shouldn't have used, or more, it will be easier to see when you have more eyes looking at it.

And bonus, you will learn more about code conventions and patterns if you do so.

Conclusion

These are things that I use in my everyday development. There are a lot more ways on how you can get unstuck on a problem. I hope this article will help you with your coding problems.

If you have any tips, you can drop them in the comment section below and help other developers get unstuck with their coding problems.

Thank you!

Comments (2)

Catalin Pit's photo

I wish I had this article when I started my career!

Dave Martinez's photo

Thanks, Catalin Pit!

It's great to hear that since you're one of the tech bloggers that inspired me to write my first article.