An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
Easy Ways to Debug Your Code (Without Crying)
Debugging code is an essential developer skill.
Use these 5 effective techniques to level up your debugging game.
Lets go!
TL;DR
- Narrow down bug scope
- Use debugging tools
- Write test for the bug
- Use rubber duck strategy
- Take a walk
Narrow down bug scope
First, identify cases for which the issue occurs.
Then, you can analyze corresponding defective code.
Navigating whole code base for fixing a bug is:
- ineffective
- tiring
- time consuming
Localize the bug before fixing it.
Use debugging tools
Spend some time learning about:
- Debugger
- Chrome Devtools
- API verification tools
- Analyzing heap dumps
- Packet sniffing tools
You dont need to learn all of them.
Only the ones that are useful for your stack.
Find what works. Use them often.
Write test for the bug
Every bug is a failing test case.
Use tests to:
- reproduce the issue
- verify the fix
Remember:
Test >> Bug documentation
They prevent future appearance of the bug.
Use rubber duck strategy
Its a fancy term for Thinking out loud.
Idea is to explain your code line by line to a rubber duck.
It forces you to come out of the perspective that introduced bugs in the first place.
Also, the tip works with pets too :)
Take a walk
While debugging you will get stuck.
A lot!
So limit the time spent in a session.
After that, take a break.
Let your mind wander.
Clear your head and come back later.
This tip works best for me.
Wrapping up
Thats it.
Hope these tips will help you in debugging your code.
Share in comments your best debugging tip.
If you liked this post, follow me for more of these
Original Link: https://dev.to/codewithvoid/easy-ways-to-debug-your-code-without-crying-1p0f
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To