I almost never Debug my code.

by Apr 30, 2024

I almost never Debug my code.

Somehow this is strange in the eyes of fellow developers. They can’t image coding without a debugger.

For example, I have never felt the need to attach a debugger to a deployed Dynamics 365 Plugin. Never!

Ok, one time. I wanted to know how to debug remotely into a Dynamics 365 environment.

I see some developers hooked on debuggers; they have a tough time coding without it.

How do I do it? Four ways:

1️⃣ Deducing

I can pretty well deduce how code works, just by looking at it and reasoning about it.

I even started programming using pen and paper, before I even had a PC. I was eagerly saving money to buy one.

2️⃣ Defensive programming

Always validate inputs into your code. Handle them by having good defaults or throw an exception with a good description of the issue.

When a bug occurs, the exception is so descriptive that I don’t need to debug to fix the issue.

3️⃣ Testing

For things that are harder to deduce or are more complex, I create tests. I test what I think should happen and verify this.

Test all the possible scenarios that you can think of.

3️⃣ Logging

I log extensively. My assumption when doing logging, is that I am not allowed to have access to the server or the machine of the user.

I often log at places where a clear next step in my code happens. Usually, the place where you would place a breakpont for the debugger.

I log as much useful information as possible so, assuming that I am not allowed to start a debug session.

When a bug happens, the logs tell me a lot about the location of the issue and how to solve it.

Often the Logging section on my Azure bill is the biggest part of a solution.

And yes, sometimes I also use a debugger, when the above ways all failed to help me out, but it doesn’t happen often.

Are you addicted to your debugger?

Subscribe to
The Daily Friction

A daily newsletter on automation and eliminating friction

Related Content

How do marketers measure campaign success?

How do marketers measure campaign success? The secret lies in UTM codes, essential tools in digital marketing analytics. UTM codes decode each click, revealing the effectiveness of your marketing endeavors across varied channels and campaigns. But here's the surprise...

read more
Share This