Foojay Today

Introducing 140 Second Ducklings: What is Debugging?

February 14, 2022

I’m launching a new twitter video series that will focus on teaching the concepts of debugging (and other concepts) in small video bites.

This is the first video in the series. I hope to publish a new video every week. It starts with the very basics of debugging and builds up. I think debugging is a powerful tool that even experienced developers don't leverage enough.

See the video here:

The source code used in the video is available here: https://github.com/shai-almog/PrimeMain

Introduction

I tried to do a debugging tutorial a while back. I’m not a fan of the result. I think I got ahead of myself a bit for novices and skipped ahead too soon. This time I’d like to keep it short. Even if you know the subject well enough, you won’t waste much time. These videos will rise in complexity to advanced debugging as in the following weeks.

My goal is to create a series that’s accessible to novice developers and also has nuggets that more experienced developers might have forgotten or didn’t know.

At the moment I am using IntelliJ/IDEA and Java. However, everything I show should work for VSCode, JavaScript and other programming languages. I plan to create similar videos for additional languages/IDEs to match.

In the first video, I focused on simple Inline breakpoints, stack trace and variable values. The second video talks about control flow, forced return, etc. I will return to the venerable breakpoint in future videos since there's so much to discuss!

I plan to cover increasingly complex concepts as we work our way through the basics. E.g. I will obviously discuss:

  • Remote debugging
  • Post-mortem debugging
  • Print statements
  • Conditional breakpoints
    and so much more...

Debugging Process

“Debugging is the scientific method applied to computer programming. We can observe a problem or a behavior directly within the running application.”

When we pick a debugging tool, it isn't that different from typical experimental science. We define what we expect to observe in the code base and we see if our expectations match reality. This analysis leads us to the solution.

The first challenge we deal with when pulling out a debugger is reproducing the issue. How do we repeat the experiment?

I will go into more details in the next episode of 140 second ducklings…

Debugging vs. Unit Tests

"It isn’t a replacement for testing. You often need a debugger to debug the tests or understand the missing tests. In fact, debugging and testing go hand in hand."

Testing and debugging go hand in hand. Debuggers are excellent tools to debug test failures. But the really significant part is that unit tests help us prevent regressions of bugs we understood in the debugger.

Extracting a unit test following a debug session is a great subject for a future video focused on testing.

Understand The Program Source Code

"Debugging provides insight into our code that’s normally much harder to get otherwise. You can use it to learn new code"

This process is more than just defect analysis...

When I need to pick up a new code base, I often start with debugging. I look through the central areas in the software code with a debugger to verify my assumptions and understandings.

It's like looking inside an engine while it's working and pausing it to understand details. Common debugging technique can reveal the hidden nuances of a software product.

Debuggers Checklist

"We start by making the simplest assumption we can about the project

Then we need to validate that assumption using the debugger. If we get a different result than what we expected, then we have something to investigate. This is the debuggers checklist which we will discuss in the future"

I wrote about the debuggers checklist in great detail a while back. I'll try to go over all of its approach as part of this series. The checklist is a generic theoretical framework or algorithm by which an application can be debugged.

This might be unnecessary for smaller samples like the one in the video. But as lines of code grow and complexity rises, we need a methodology for locating bugs.

Next Week and Down the Line

I plan to post a video every week. I hope I can keep up. I have the next one ready but production is non-trivial. Hopefully, this will get easier with practice.

I hope to introduce additional topics to the "140 second ducklings" series. There's so much I want to cover. An interesting subject would be DevOps for developers or tracking production issues.

Topics:

Related Articles

View All
  • 8 Debugging Tips for IntelliJ IDEA Users You Never Knew Existed

    As developers, we’re all familiar with debuggers. We use debugging tools on a daily basis – they’re an essential part of programming. But let’s be honest. Usually, we only use the breakpoint option. If we’re feeling frisky, we might use a conditional breakpoint.

    But guess what, the IntelliJ IDEA debugger has many powerful and cutting-edge features that are useful for debugging more easily and efficiently.

    Read More
    Avatar photo
    Sep 09, 2021
  • Book Review: “Quarkus for Spring Developers”

    Quarkus for Spring Developers is a straight-forward guide to enable senior developers to quickly shift their Spring skills to leverage the “supersonic subatomic” Quarkus framework, and junior/mid-level developers to learn two frameworks at once.

    The book gets straight to the point of Quarkus’ speed before the first chapter, with the foreword providing a real world testimonial of Quarkus software that many Java developers already use.

    Read More
    Avatar photo
    Oct 04, 2021
  • Debugging Java on the Command Line

    Some bugs are hard to replicate on your personal computer but easily replicated on production or test machines. It is a common situation that professional Java developers deal with frequently. To debug such problems, OpenJDK provides two tools, remote debugging and jdb.

    This article focuses on jdb.

    For Java applications, typical production and test machines are Linux servers without display managers, so that only command line tools are available. Here we cannot use professional IDEs like IntelliJ IDEA, Eclipse, or Apache NetBeans IDE.

    In such scenarios, we can use jdb. jdb is a command line debugger and it is part of the OpenJDK.

    Read More
    Avatar photo
    Jun 24, 2021

Author(s)

  • Shai Almog

    Developer Advocate at Lightrun. Co-Founder of Codename One. Java Rockstar, Speaker, Author, Blogger, open source hacker and pizza enthusiast

Comments (0)

Your email address will not be published. Required fields are marked *

Highlight your code snippets using [code lang="language name"] shortcode. Just insert your code between opening and closing tag: [code lang="java"] code [/code]. Or specify another language.

Save my name, email, and website in this browser for the next time I comment.

Subscribe to foojay updates:

https://foojay.io/feed/
Copied to the clipboard