How do you navigate the challenges when your code fails to function as anticipated or yields unexpected outcomes?
Share your experiences, strategies, and lessons learned in handling such situations.
Follow the DEVteam for more discussions and online camaraderie!
Top comments (3)
I believe the single most important thing in these scenarios is logs.
If you have proper logs in place, you can
identify the input parameters
e.g. What was the request body? Or function arguments?
trace the flow of execution
e.g. What was the sequence of functions called for this request? Did these functions work as expected?
identify the area of fault
e.g. If a sequence of functions are being called, which one seems to be giving a faulty output?
Sometimes, the logs may tell you exactly what went wrong.
Other times, it may at least give you some leads on what the problem might be.
Based on the logged input parameters, you might be able to reproduce the erroneous behavior on local or testing environment. And with further debugging and testing, you may identify the issue.
I "sleep" it. Literally I go to sleep until next day, and then my brain gives me a solution.
By... debugging them?
WTH do you expect, honestly.
/satire