Purposefully debugging without using a debugger?

后端 未结 20 1829
春和景丽
春和景丽 2021-02-01 08:49

In chapter 5 of \"The Practice of Programming\" Brian Kernighan and Rob Pike write:

As a personal choice, we tend not to use debuggers beyond getting a st

20条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 09:39

    Print statements tend to produce output that you can look at and reason about for quite some time, whereas when using a debugger you are forced to memorize the past, know exactly what is going on at present, and exactly what should happen in the future.

    For example, you have an algorithm that changes a variable 100 times. On the 85th time, it got changed to a value that should never have been assigned to it in that case. With a debugger, you are forced to step through that 85 times. Conditional breakpoints may alleviate some of this.

提交回复
热议问题