DEV Community

Cover image for What are your debugging tips?
Ben Halpern
Ben Halpern Subscriber

Posted on

What are your debugging tips?

Oldest comments (23)

Collapse
 
gabrielpedroza profile image
Gabriel Pedroza

Run the same code 4 more times to make sure it’s a real bug. If it is, it’s time to get the rubber ducky🐥

Collapse
 
pozda profile image
Ivan Pozderac

If ducky can't help, I just ask this senior web developer for advice!

Ducky and senior web developer hanging out together

Collapse
 
warwait profile image
Parker Waiters

Get systematic: Remove possible variables in the code until you can isolate the problem. This is why it's important to be disciplined with your version control so you can freely delete swaths of code without complicating your life by being in the middle of some huge edits when you're trying to do it.

Collapse
 
mcsee profile image
Maxi Contieri

Add a failing test.

Debug it in isolation

Collapse
 
iamschulz profile image
Daniel Schulz

I got a few:

  • Breakpoints for assignment problems, loggers for flow problems.
  • Document your bugs, you'll see them again.
  • Fix a bug, then write a test for it.
  • Does it break the product? It's a bug. Is it just inconvinient? It's a feature request.
  • Talking a walk outside is a valid bugfixing strategy.
Collapse
 
frikishaan profile image
Ishaan Sheikh

Use breakpoints.

Collapse
 
canro91 profile image
Cesar Aguirre
  • Isolate your problem
  • Think out loud. Talk to your rubber duck
  • Find how others have solved the same problem
Collapse
 
paulasantamaria profile image
Paula Santamaría
  • Isolate the problem
  • Focus on solving one problem at a time
  • Make sure you locate the real source of the issue and not just a symptom
Collapse
 
marinsborg profile image
Marinsborg.com

I agree with what people already wrote here. Maybe good idea would be to take pen and paper and draw what code does on more abstract level and then start with rubber duck method.

Collapse
 
pbouillon profile image
Pierre Bouillon

Sleep on it

I can't even remember how many times I was stuck on a problem for hours and it just took some minutes to solve the next morning after some rest

Collapse
 
fen1499 profile image
Fen
  • Log as much things as possible
  • Make proper use of exceptions
  • Have a nice night of sleep