Addy Osmani’s Post

View profile for Addy Osmani, graphic

Engineering Leader, Google Chrome. Best-selling Author. Speaker. I want to see you win.

There are many valid Debugging Tactics :) When you're debugging a system, the first step is to accept that what you believe about how it works might not be true. If everything were as you believe it to be, then your code would work—but obviously that's not always the case. I'll share a few (common) debugging techniques that have worked well for me I just posted: https://lnkd.in/gHpbKnDc Take a walk ---------------------- One of the best tools to debug code is walking away for 10-15 minutes If you recognize that you are frustrated, stuck on a tricky problem, or running around in circles—take a break. A five to fifteen minute walk will help re-energize and reset your physiological state. You may return with new solutions! Sometimes all we need is a little perspective to help us solve our problems. Rubberducking ---------------------------- When you explain a problem to someone else, the important thing is not just who you're speaking with but that in doing so, you are also explaining it to yourself. When you teach someone else, you often find inconsistencies in your assumptions about the subject and are forced to take a new perspective. Actually read the error message -------------------------------- Something often overlooked when debugging is to read the error message. Your tools usually give you a lot of information about the problem, and it can be more helpful than you think. Read the docs -------------------------------- Read the docs before trying to debug This is an obvious one, but it's often overlooked. I've seen people jump through all kinds of hoops in order to figure out why something they're doing isn't working, when all they had to do was read the documentation and realize that they were using a function or method incorrectly. Run the same code again ---------------------------------------------- If you have a problem that is intermittent, then running the same code again may help diagnose the issue. This can be helpful if you are trying to diagnose: - A timing issue - Race condition - Code with non-deterministic execution - Code influenced by external factors like network latency 1st page of Googling / StackOverflow -------------------------------------- You can often find other people who have run into the same problem and solved it, or at least have some ideas on how to approach the problem. Logging ------------------- Developers often insert temporary logging statements (e.g. console.log(), print) in the code to check values during code execution. You can also use these statements to check the values of variables in between lines of code. Conclusion --------------------- There are many valid approaches to debugging. Questions you can ask yourself: What is the goal of the code? What does the code actually do? What are the issues you found with the code? Have you encountered these kinds of issues before? What did you do to fix them last time? What do you think caused the bugs? #softwareengineering #programming

Debugging Tactics

Debugging Tactics

addyosmani.com

Nate Lubeck

Let's elevate your brand with innovative and creative solutions! As a Creative Technologist, I'm passionate about transforming your vision with resilience, empathy, and cutting-edge strategies.

2y

i love using breakpoints, until i get into a 3rd party minified library with no sourcemaps.

There are times when I've become discouraged when there is a bug, and it is a new kind of bug I haven't dealt with before. Sometimes sleeping on it helps me dream about possible solutions and solve it the next day. However it isn't always that easy. Experiences like this (when I'm in the battle of the code and feeling the heat) honestly make me question my skill level and whether or not I'm good enough to be considered a regular "software engineer" instead of a "junior software engineer"... That's when I know it's time for a break. When high profile, more experienced software engineers can be intellectually humble enough to tell the newbies that they still struggle at times and deal with bugs like the rest of us. Well, it is what it is - encouraging.

i talk with the PC, i use to offend him quite a lot 🤣

Gurukiran S

Co-Founder & CTO at Zeru

2y

print("gotcha here is the culprit!")

Print statements 4 lyfe. Love this post.

Alexej S.

Software Test Engineer

2y

I like taking a walk with my rubber duck ;)

Daniel Faure

Creating solutions with 𝗞𝗹𝗮𝗸 🇦🇷

2y

Many times, when I find a problem I cannot solve, what I do is break the code, for instance, deleting a necessary opening bracket, so, hoping to read an error on error log. Why? I spent once about an hour making meaningless changes on the script opened on Editor, but it was just another with the same filename and living on a sibling folder.

Feng Liu

Smart Mobility Platform Software Consultant at Ford Motor Company

2y

I am seeing a correlation here that the less of something you do the more effective it is.

  • No alternative text description for this image

Insightful, Addy Osmani. On a lighter note, from my good old PowerBuilder days in the mid '90s, a co-developer got a 'bug ticket' from the testing team that said, "I get an error message that says price cannot be greater than $100". My friend, quietly removed the MessageBox, and resubmitted the build. :-) It is important that the testers explain the problem clearly to avoid confusions. 🙏🙏

See more comments

To view or add a comment, sign in

Explore topics