The Case Against "Try This" Debugging

In many group debugging sessions I’ve joined, a major technique being deployed is something I call “Try This” debugging. In this post, I’d like to talk about this anti-pattern, and consider a better way. “Try This” Debugging Defined What is “try this” debugging? Imagine we’re debugging as a pair and we’re stuck. The easy answers aren’t working. Suddenly, I produce an idea. It might be a: Stack Overflow answer GitHub Gist Popular comment on a GitHub issue Slack post from a colleague I share this with you and say the magic words: “try this.” ...

June 26, 2023

You Can't Change Nothing

I saw a meme this week: a person debugging code, “My code doesn’t work. Let’s change nothing and run it again.” This is something that I’ve done. It seems pointless. But that’s not quite correct. Repeatedly “running it again”, by loading a page, printing something, or starting an automated test, without making a prediction– yes, this is a bad practice. But sometimes trying something twice is a solid technique. The reason is that even if you don’t make a change, that doesn’t mean that nothing has changed. ...

October 21, 2022

All My Best Debugging Tips

This is a list of all the best debugging tips I’ve picked up over the years. Some of these might seem obvious, yet we forget them when it counts. Debugging is a skill. You have to bring every tool you have to the job. 🚀 Update: this became an e-book! Don’t Stay Stuck: A Debugging Guide for Rising Engineers is my concise, actionable guide to debugging like a pro. Check it out! ...

August 5, 2022

Recognizing and Repairing a Broken Mental Model

Perhaps you’re familiar with this scenario: you’re debugging and stuck. You’ve Googled, read some blog posts and docs. You return to your search engine, type some characters, and then something strange happens: the search engine autocompletes your question, and the results are all purple because they have been visited by you. I’ve come to recognize this moment as always a symptom of a broken mental model. A broken mental model is a fundamentally flawed understanding of how something works. It derails problem-solving by leading us to ask bad questions. Bad questions beget bad answers. ...

July 25, 2022

Logging an Object in JavaScript

When printing a JavaScript value to the console, I suggest using an object literal over the raw value. // Okay console.log(response) // Better console.log({ response }) It’s a little thing that over time has a big benefit. In this post, I’ll explain this technique and describe why I find it useful. First Iteration: The Raw Value Imagine you have a value assigned to the variable response, and you want to know its value. Here’s how you might print it to the console, with console.log. ...

July 7, 2022

How to Write a Perfect Bug Report (With Template)

Bugs are part of software. Reporting bugs well is a necessary skill in an ever-growing number of job titles. In this post, I’d like to explain how to write a perfect bug report and offer some bug-reporting best practices. What do I mean by ‘perfect’? A perfect bug report allows the receiver to start effectively solving the problem without additional conversation. I’ve found that it’s the standard on great teams. ...

June 13, 2022

Make a Prediction

Imagine you’re debugging, and you’re stuck. I have a technique that’s going to help. Think of an action you might take. Predict what will happen when you take that action. Take the action. Check if you were right or wrong, consider that information, and repeat. This may sound simple, but it’s incredibly powerful. Here’s how it works. Making a Prediction Imagine you’re debugging a web application, and you’re trying to understand why some data on your page looks wrong. ...

June 8, 2022

How to Identify the Breaking Commit With Git Bisect

Some code is broken, and you can’t figure out why. Maybe there are a lot of changes, and identifying the breaking change seems impossible. Or, maybe you’re curious about how things break in your organization. The tool you need is git-bisect. Git bisect conducts a binary search through your Git history to find a commit of interest. In this post, I’ll show how it works. A Caveat: Atomic Commits Required For bisect to be useful, you must be committing atomically. If your practice is to squash-merge PRs, or commit swaths of unrelated code with each commit, a bisect may only tell you that something broke when you merged in a huge PR. That can be, isn’t always, useful information. ...

May 17, 2022

The Problems With Code Screenshots

Screenshots of code are common in developer communication, but they come with real drawbacks. Here’s why I try to avoid them. Screenshots happen. People are often under time pressure, on phones, or unfamiliar with best practices. Some people feel more confident communicating with images. I’m here to offer solutions, not shame. Problem Background Why does one post screenshots? To be helpful. You’re stuck and want to provide high-bandwidth information. What could be higher bandwidth than a picture? I appreciate that helpful spirit. ...

April 19, 2022

How to Read a Stack Trace

A stumbling block for many people when debugging is reading the stack trace. Today I’d like to discuss this important skill. What is a Stack Trace? What is a stack trace? According to Wikipedia: “In computing, a stack trace… is a report of the active stack frames at a certain point in time during the execution of a program.” It’s the answer to the question: “when this system is being observed, what is happening?” Reading stack traces is a core programming skill. ...

April 5, 2022