by 0xFEE1DEAD · 1y ago · 0 comments
That being said even with 100% coverage your code may still contain bugs. If you've never had to debug code with extensive tests then hats off to you.
I expect that is what the parent is really asking about: What does this meaningfully offer over the "built-in" debug logging?
Maybe I'm just old, maybe it's just a different approach, but I built dlg for myself because it fits my workflow.
> What does this meaningfully offer over the "built-in" debug logging?
For you, it most likely doesn't offer anything meaningful.
For devs who use fmt.Printf a lot, it maybe does.
"100% coverage" is just a measure of line coverage and is highly useless to reason about.
For testing to become meaningful, you should have test data covering way more than that for the relevant parts.
I'm not saying that tests are perfect, but if you do find a bug, you write a new test and fix it. You don't add print statements that you expect to keep around any longer than the amount of effort there is to write the test and fix the code.
Maybe this product is for people who don't write tests, but even in this codebase, there is a pretty well done set of tests and zero dogfood usage that I noticed.
Maybe there's a misunderstanding here but this library is not meant to replace tests. It's for initially finding the bug for which you then write a test case (or not).
If you write tests, you don't need a specialized library for debug logging.
Run the test, and set a breakpoint in your debugger.
Software developers who...
1. Experienced actual instruction on software development;
2. Learned to write software in C/C++/FORTRAN/Pascal/whatever; or
3. Spent a lot of time in more niche situations like system programming, embedded programming, enterprise systems, etc.
...are familiar with using debuggers as part of their workflow to inspect internal state and diagnose. In contrast, developers who...
1. Were entirely self-taught;
2. Grew up on interpreted languages (JS, Python, PHP, Perl, etc); and
3. Generally tend to write smaller, self-contained projects
...tend to just add debug logging and re-run the program.
I definitely have used debuggers in the past, but as someone who almost exclusively has written in interpreted languages (or languages where the write-compile-run loop is fast, e.g. Golang), my habit is to add debug logging to more places to validate internal state as the program runs, rather than attaching a debugger and inspecting specific things manually.
Either way, I think it's two separate approaches and I think in different circumstances there are definitely benefits to one or the other. In most of my Python scripts it's faster to add a `print(f"variable is {variable}")` than it would be to attach a debugger; also for a small script that's only going to run a few times, or run very occasionally, writing unit tests is often overkill because often the entire script is effectively a unit.