DEV Community

Cover image for 5 Tips to Solve your Problems as a Developer
Gaël Thomas for HereWeCode

Posted on • Updated on • Originally published at

5 Tips to Solve your Problems as a Developer

We all know that being stuck on a programming issue can be frustrating. As a developer, I asked myself how to overcome this feeling. In this post, I will share with you my top 5 tips to solve issues.

For the past few days, I've been thinking about: "What can I do if I get stuck on a programming problem". In the beginning, I did it for myself, but today, after spending my day stuck on several issues, I decided to share it. It could help a few people!

I created this list of tips based on my own experience as a programmer and teacher as a freelancer. I wanted to keep it short. Everyone can print it, put it on their desk, and read it every time they are facing this common issue.

Ask yourself

90 percent of the time, when my students came to me with code errors these two questions solved their issue:

  • If an error is displayed in the terminal: "Did you try to search the error on Google?". Don't worry too much about finding the solution by yourself. If you have an issue, someone may have the same before!

  • "Did you take the time to print all the variables?". Code is about data, and most of the time, bugs appear when the wrong type of data is sent to a piece of code. My first recommendation will always be to take the time to display the content of all your variables.
    As an example: if your issue is around line 50 in your code. Print everything before line 50 to have a global view of the problem.

It's always more practical to understand a bug when you have all the information in front of you.

Since I started to code, it happened a few times, and recently again. I'm stuck, and I'm sure to know the data-structure of my variable. In the end, when I printed the content, it was not exactly what I expected.

Recognise you're stuck, take a break

Most of the time, when we are stuck, we don't want to leave our computer. We think we didn't search enough. We want to start the same process again and again until finding a way to solve our issue.

"It's impossible, I should solve this issue. I've checked everything, how can it happen?"

If you recognise yourself in the quote above, you should take a break!

What I like to do when I'm stuck on a problem is take a coffee, then do something else. It can be, talk to my colleagues, read a blog post, or going for a walk.

I recommend you to find a relaxing activity—the one you can use anytime, and anywhere.

Once you are back to your code, you will feel more relaxed, and you will approach your issue in a better way.

Nothing is better than the paper

Once you feel stuck on an issue, take the time to write it on the paper.

It's an excellent tool to summarise a problem and think about it.

Sometimes your computer screen can be disturbing. The reason is that you have many windows open with all your code stuff and it's hard to focus on the problem itself.

The goal of this step is to demystify the problem.

"I have a solution, but I don't like it, it's not the best one."

When you're programming on a project, you like to build beautiful code. Unfortunately, sometimes you have a solution to your problem, but it's not the best one, and you know it!

It's not a good move to stay on it for hours. If you want, you can set a timer to have extra time to think about it. But once it's ended, write your idea and leave a TODO's comment (// TODO: Find a better way to do this.).

I like doing this when I know this is not the best way to do it. Most of the time, the next morning, you will open your computer, you will find a way to improve your code in only 10 minutes.

You can trust me because this is a developer fact! Most of my developer friends told me about this.

Ask for help

Don't be scared to ask other developers! If you think you've tried all the tips above, I would recommend following this shortlist to ask for help:

  1. Take a short break.
  2. Write your problem again on the paper. I recommend you to do it like if you're going to show this paper as an explanation of the issue. It's a kind of summary to explain your problem and organise your mind. Explain the problem to yourself another time. Are you ready to explain it to your colleague? At this step, do you feel more comfortable with the issue? Does this process give your other ideas to try? If yes, go back to your project and try them.
  3. Ask your colleague, and explain the problem in detail. If possible show examples or do a demonstration, it's better to understand the issue in depth.

Work on something else then come back later

We can classify this tip to the same category as the "take a break" one.

Sometimes you're tired of working on a specific part of your project, so switch to another task.

Don't take a long or difficult one; do something more simple than what you're doing actually. You will see how it's satisfying!

I want to share a recent example from my developer life.

In my company, I'm working on a new feature for more than three weeks. A few days ago, I was stuck in the implementation, and I started to become a bit upset. I wanted to finish, and I was frustrated.

I took a break from this task and moved on another small project which was more simple to develop. This project took me two days to do, and after I was super motivated and ready to go back to my previous main project.

If you want more content like this, you can follow me on Twitter, where I tweet about web development, self-improvement, and my journey as a fullstack developer!

Top comments (8)

jacklowrie profile image
Jack Lowrie • Edited

I love the TODO suggestion because it stops the perfect becoming the enemy of the good. For me, that also acts as a 'mental dump' -- it's being tracked in the code, so my mind relaxes knowing it doesn't need to remember to come back to fix whatever code I'm not satisfied with!

gaelgthomas profile image
Gaël Thomas

I'm glad you like it! I started using it a few months ago when I got my full-time job, and it saved me a lot of time.
It's a habit to develop, but I always come back to my TODOs with fresh ideas.

annietaylorchen profile image
Annie Taylor Chen

Yeah... my problem is also that I tend to get stuck at one problem for hours and even days and I can't move on! Then many times, the second day you suddenly found a way to solve it. It's really important to learn to have breaks and have boundaries. Being a developer can be a bliss and curse at the same time.

For me I have another problem : no CS as base, so sometimes I also wonder, if I have that, will I have a different way of thinking? a different approach? Will I solve it quicker if I am a CS grad? So... I guess eventually I have to pick up some stuff I didn't learn before.

gaelgthomas profile image
Gaël Thomas

I don't think that you need a CS degree to become a good developer.
What I would suggest is to practice as more as you can. Try to create projects and build them.
The practice is the key. The more you practice, the more you will be able to solve problems. You will develop a programmer way of thinking, and you'll get used to more and more common issues.
Keep coding! 😀

iainfreestone profile image
Iain Freestone • Edited

Great article. One thing I find works for me often is just saying the problem out loud rather than in my head. This technique is called rubber duck debugging.

gaelgthomas profile image
Gaël Thomas

Thank you!
Ahaha, I read the post you mentioned. I love the conversation example given by Natalie. You made me discover a new thing. It's a way to reformulate a problem, if it's working for you that's great!

karthick30 profile image

Exactly taking a break and writing it in on paper are life saver !

gaelgthomas profile image
Gaël Thomas