Showing posts with label debugging. Show all posts
Showing posts with label debugging. Show all posts

Tuesday, October 27, 2020

Improving Your Debugging Strategies by Chelsea Troy

 I really like this article by Chelsea Troy in Functionize.

https://www.functionize.com/blog/improve-your-debugging-strategies/

Most developers know the standard strategy of debugging that she highlights. I would paraphrase her standard strategy term as "speeding through debugging with random breakpoints based on what developer believe is causing the issue." Like the author points out, this strategy is usually not the best unless you already know the the entire code base of the application or system. With the vast inter-communication among multiple apps, I doubt most developers today have this capacity to store an entire code base in human memory.

She defines another term called the investigation strategy. This strategy uses an existing algorithm to find the root cause of the issue like a binary search. The point isn't to list all the approaches to debugging but to understand that a better strategy is needed to improve your debugging skills. And, it should be language-agnostic as well as independent of any debugging tools (although it's helpful).

Thanks, Chelsea.



Wednesday, April 24, 2019

Reuse: 16 ways to find elements in Chrome browser

I totally forgot that jquery could be used in the Chome console panel until I saw a mentor do this during a demo.

Here's a blog on quick tips to find elements in Chrome browser.
https://www.telerik.com/blogs/16-ways-to-search-find-and-edit-with-chrome-devtools

Thursday, October 25, 2018

Debugging Errors - Trailing Whitespace in Properties file

Problem

Well, I know this seems minor, but when you're using Properties file to maintain a list of usernames/passwords for a Test Script that tests logging in as each user (because a specific user role is associated to these demo users), then this is a good way to maintain testing of the application's login.

So, long story short, one of users would crash the browser by hanging up the login page when attempting to login.

Solution

Long story short, I had one whitespace char trailing the username. So instead of the username being "user1", it was "user1 ". This whitespace char was not caught and handled well in the application which is now fixed, but this took a lot of time to debug. Unnecessarily.

Be sure that your Properties file has the property value as expected. Use a text editor displaying all characters in file, if need be.

Cheerios!

Thursday, September 1, 2016

Debugging - PHP + Javascript - Unexpected Token <

I recently came across an unusual error in the JavaScript Console when processing my PHP code into JavaScript to display in the browser. The line number provided in the console is misleading - b/c it's not the actual line number with the error. So I don't use the 'line number' information to debug.

Error

Code

The root cause is how either PHP is calculating the 'addition assignment' operation (i.e. a += b; ) within JavaScript tags during compilation or how JavaScript is processing the PHP output before displaying to the browser. I'm not exactly sure as this would require more research and investigation on my part which I don't currently have time - yay, deadlines!



Initial Attempt

At first, I thought I needed to replace the shorthand 'addition assignment' operator into its expanded equivalent. (See the green arrow in my image below.)


The expanded equivalent would be:
a = a +b;
or according to my code:
// line 91
$num_of_users_per_org[$k][1] = $num_of_users_per_org[$k][1] + 1;

Solution

At last (within 5 minutes), I figured out that I need to initialize the 2nd array in my multi-dimensional array corresponding to 'user_count'.  (See the light green arrow in my image below.)



Proof

After adding the code and rendering again in the browser, our results pass and the code works. Bingo!

Click on image to enlarge (see clearly)

Nice Debugging Reference