4 ms·
This is how I write code today! Everything needs a catchy name, so I call it Debugger Driven Development. I write the first few lines of a function, however m
by Stratoscope 5y ago
This is how I write code today!
Everything needs a catchy name, so I call it Debugger Driven Development.
I write the first few lines of a function, however much I feel sure about, then add a dummy statement at the end and set a breakpoint there. When the code stops at the breakpoint, I can see exactly what my code did and what data I now have on hand.
I use that new knowledge to write the next few lines, again until I get to something I'm unsure of or where I'd just like to get a better view of the data. Set a breakpoint there and view that new data.
Repeat as needed until the function is done.
At my work we have many internal APIs that are "documented" but the documentation is fairly lacking. With the debugger, I can see not only what the API claims to do, but what it really does with my actual input.
I am bummed that so many developers today eschew debuggers. I even read an article recently along the lines of "These famous programmers don't use debuggers, and you shouldn't either". Why would anyone want to talk people out of using such a useful tool? It makes no sense to me.
- saagarjha 5y agoIt’s sadly fallen victim to the “if you’re not using a debugger you’re not a real programmer” reversal.
- jamesfinlayson 5y agoI'd love to use a debugger more, but in my day job at least, the use of Docker makes it a hassle to set up. For standalone Java applications, or when using Visual C++ though, it's so much better than printing out state.
- Annatar 5y agoWe did that in the 1980’s and the 1990’s on the Commodore 64 and the Amiga, only then the debugger was called a monitor and it was quickly discovered that programming in them was slow and error prone because they lacked the ability to recompute. That is how assemblers were invented: Turbo Assembler on the Commodore 64 and ASM-One, TRASH’M-One, Seka and MasterSeka on the Amiga. ASM-One and TRASH’M-One include an excellent debugger built natively into the integrated development environment, and stepping through the code after assembling it is a joy.
- djmips 5y agoTrue! but that's not how assemblers were invented. Assemblers were around since the sixties at least.
- mejutoco 5y agoReminds me of Common Lisp with slime. https://dev.to/kmruiz/working-with-your-running-program-an-interactive-environment-1jpa https://dev.to/kmruiz/working-with-your-running-program-an-i...
- userbinator 5y agoI am bummed that so many developers today eschew debuggers. I even read an article recently along the lines of "These famous programmers don't use debuggers, and you shouldn't either". Why would anyone want to talk people out of using such a useful tool? It makes no sense to me. That would be because of what I call "long vs. short-term". If you're only thinking of the next few lines and doing that a lot, you will have effectively trained yourself out of looking at the bigger picture. As someone who taught programmers, I've seen what "debugger driven development" code looks like (because that's how some of them will try to start writing code.) It's not pretty. There's a reason a lot of highly productive (but not necessarily famous) programmers consider debuggers as a last-resort tool: writing code that needs debugging should be a rare occurrence.