← 返回起始笔记位置

知识卡片

普通读书笔记卡 · 8777.c · 生成模型:GPT-6

死代码判断包括副作用与可达性

理解等级:高级

结果未参与后续计算不等于无作用,表达式可能写文件、记录或影响状态;另一类死代码是永不可达路径。删除前确认数据流、副作用和外部消费,不能只凭返回值未用做判断。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      Dead code is code that is executed but its result is never used in any other computation. Dead code is yet another unrelated thing that developers have to hold in their heads when coding. It adds unnecessary cognitive burden. If there’s code that does not change the result of the program, whether it runs or not, then it’s not required for the code to run.

    参考来源

    - 位置:《Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)》第08章《重构与技术债》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)/_epub-src/OEBPS/ch08.html) - 结论依据:摘录中关于死代码判断包括副作用与可达性的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:Dead code is code that is executed but its result is never used in any other computation. Dead code is yet another unrelated thing that developers have to hold in their heads when coding. It adds unnecessary cognitive burden. If there’s code that does not change the result of the program, whether it runs or not, then it’s not required for the code to run.