|
Post by account_disabled on Jan 29, 2024 3:53:11 GMT -6
软件开发很复杂,在某些时候,您的 Node.js 应用程序将会失败。如果幸运的话,您的代码将会崩溃并出现明显的错误消息。如果您不幸运,您的应用程序将继续运行,但不会产生您期望的结果。如果你真的不走运,一切都会正常工作,直到第一个用户发现灾难性的磁盘擦除错误。 Play Next Unmute Current Time 0:03 / Duration 2:00 Fullscreen Backward Skip 10s Play Video Forward Skip 10s 什么是调试? 调试是修复软件缺陷的黑魔法。修复错误通常很容易——纠正一个字符或添加一行代码就可以解决问题。查找错误是另一回事,开发人员可能会花费许多不愉快的时间来尝试找到问题的根源。幸运的是,Node.js 有一些很棒的工具来帮助跟踪错误。 术语 调试有自己选择的晦涩术语,包括以下内容: 学期 解释 断点 调试器停止程序以便检查其状态的点 调试器 提供调试功能的工具,例如逐行运行代码以检查内部变量状态 特征 正如声明中所说:“这不是一个错误,而是一个功能”。 所有开发人员在其职业生涯的某个时刻都会这么说 频率 错误发生的频率或条件 它不起作用 最常见但最无用的错误报告 记录点 给调试器的指令,用于显示执行期间某个点的变量值 记录 将运行时信息输出到控制台或文件 逻辑错误 该程序可以运行,但未按预期运行 优先事 WhatsApp 号码数据 项 其中错误被分配到计划更新列表中 竞争条件 难以追踪的错误取决于不可控事件的顺序或时间 重构 重写代码以提高可读性和可维护性 回归 先前修复的错误再次出现,可能是由于其他更新 有关的 与另一个错误相似或相关的错误 复制 导致错误所需的步骤 RTFM 错误 用户无能伪装成错误报告,通常会回复“阅读翻转手册” 步入 在调试器中逐行运行代码时,单步执行被调用的函数 走出去 逐行运行时,完成当前函数的执行并返回到调用代码 跨过去 逐行运行时,完成命令的执行,而不单步执行它调用的函数 严重程度 bug 对系统的影响。 例如,数据丢失通常被认为比 UI 问题更成问题,除非发生频率非常低 堆栈跟踪 错误发生之前调用的所有函数的历史列表 语法错误 印刷错误,例如console.lug() 用户错误 由用户而不是应用程序引起的错误,但仍然可能会导致更新,具体取决于该人的资历 手表 在调试器执行期间要检查的变量 观察点 与断点类似,不同之处在于当变量设置为特定值时程序停止 Learn to Code with JavaScript 如何避免错误 在测试应用程序之前通常可以防止错误...... 使用好的代码编辑器 一个好的代码编辑器将提供许多功能,包括行编号、自动完成、颜色编码、括号匹配、格式化、自动缩进、变量重命名、片段重用、对象检查、函数导航、参数提示、重构、无法访问的代码检测、建议、类型检查等等。 Node.js 开发人员对VS Code、Atom和Brackets等免费编辑器以及大量商业替代品的选择感到眼花缭乱。
|
|