Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 22, 2022 11:18 pm GMT

Tips to debug code

Bugs are frustrating. It is terrible. But to debug it, it is an art that you need to master. You need to have a mindset to not falter.
So this is the tips that I can come out of to debug your code

  1. Reproduce the behaviour of the bugs
    Take the payload or anything that make the bug comes out. Reproduce it. Regenerate it. Whatever you can do. Simulate it back. This is the first things that you need to do, to see what is the problem

  2. Go back to where it last worked
    This is the most easiest way. Add the code little by little and see, which code segments that produce the bugs. It takes time, but hey, at least we have progress right?

  3. Make changes one by one. Little by littles
    Speed and efficiency are good for programmers, but when it comes to bug, we need to be delicate. It is frustrating, but still we need to go through it. Changing many things at a time won't help you to find the bug and fix it. Change something, rerun, and see the output. REPEAT.

  4. Get your colleagues to have fresh perspective
    Don't stuck yourself for hours or days to fix the same things. Ask your colleagues to see from a new perspective. Take some time off and get fresh eyes on the bug. Get a different point of view

  5. Be responsible of the code
    Firstly, don't ever blame the compiler. Blame yourself. Assume that the problems is ours and never expect the code to work for the first time so that you don't get your hope high. Of course this will comes from experience. Have a mindset to throw away the code/module if you have to fix it 5-6 times or more. Just start from scratch. Start new. Sometimes, that's the wisest things to do

  6. Learn from the bug
    This is self explanatory. Each of the bugs that we produce, learn from it. Try to not repeat it in other projects. Ask yourself, and reflect

    • "What can I learn from this?"
    • "What did I do?"
    • "How could I prevent this in the future?""Is there any tools or things that I can do to improve my coding skills?"With this mindset, slowly but surely, you will become a good programmer.

I guess that's all for now. If you have any other tips, do share it in the comment section below!

Cover Photo by Chris Ried on Unsplash

Thank you for reading :D

Psstt pstt :p
Do consider to love this article and follow me! Why not right? It's FREE~
I would really appreciate it
Will be posting more on things related to AWS, Javascript, Python, Serverless and more!


Original Link: https://dev.to/harithzainudin/tips-to-debug-code-3426

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To