Toby-Leeder / CSABlog

MIT License
0 stars 0 forks source link

Debugging #6

Open Toby-Leeder opened 6 months ago

Toby-Leeder commented 6 months ago

I was having a strange issue where the links were not being properly redirected to for my QR code project. I really want to finish this QR code thing and get it behind me so I can start on something new, so I'm hoping to fix the bug now and be done with it. I wanted to be able to see all of the variables before the automatic redirect, so breakpoints were perfect so as to not lose the variables and data from the original page.

Screen Shot 2024-03-07 at 11 52 53 AM

Here I first wanted to check to ensure that the backend call was working correctly. It's a pretty simple call and after analyzing this breakpoint I saw that this was not the issue.

Screen Shot 2024-03-07 at 11 56 25 AM

This was the first breakpoint. It was within a for loop in which intervals is built, so I was able to analyze each new addition to intervals.

Screen Shot 2024-03-07 at 11 56 44 AM

This is the first point, working as intended.

Screen Shot 2024-03-07 at 11 57 35 AM

This is the second point, which is not working as intended. This should be 0.75, as it should add the previous value of .5 with the next frequency of 0.25.

Screen Shot 2024-03-07 at 11 58 24 AM

This is the third and final interval being added. None of these intervals should be above 1 so it's not quite right, but actually it should have added .25 to the previous value which it did do correctly. It looks like this is the issue and why the code is not running correctly.

Screen Shot 2024-03-07 at 11 59 18 AM

This second breakpoint was placed in case there was some issue with the comparison of num and intervals causing the bug.

Screen Shot 2024-03-07 at 12 02 30 PM

Using this breakpoint I can see that it is functioning as intended. When i = 0, shown by the breakpoint as the current state, it should compare .622 < .5 and not return the function, continuing the loop. When I continue playing to find this breakpoint again, I see that this is the case and the next comparison works correctly (given incorrect input data).

Screen Shot 2024-03-07 at 12 03 24 PM

Now it is compating .622 < 1, since i = 1 (again shown by the breakpoint). This in theory should redirect me to the page. And when I run the code....

Screen Shot 2024-03-07 at 12 04 01 PM

It correctly redirects me to the second link. Through this process I identified that something is wrong with my logic creating the list of frequencies, and that's what I need to fix.

isabelle926 commented 6 months ago

2.0/2.0

Toby clearly explained each step of his debugging process and showed understanding of the code that he was working with. In addition, he had a valuable debugging session where he was able to fix an issue with his code that was apparent before the session and relevant to the project.