知识卡片
提取与内联按职责命名
将有明确目的的表达式或代码块提取为变量或函数,并给表达意图的名称;需要时可内联无价值间接层。提取需核对输入、返回和副作用,不能只因10行变1行就认为结构一定改善。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 代码编辑器生产力
原书出处 · 1 处
- · 查看原书依据
Extract variable/method/function These shortcuts (see Table 7-9) help you to easily execute common refactoring techniques that will make your code more readable and maintainable. “Extract method” sounds like a complicated phrase, but it’s actually a simple practice of, well, extracting a code fragment (it can be a line or a block) into a function or method with a sensible name that describes the purpose of
参考来源
- 位置:《Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)》第07章《代码编辑器生产力》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Effective Machine Learning Teams (David Tan, Ada Leung, David Colls)/_epub-src/OEBPS/ch07.html)
- 结论依据:摘录中关于提取与内联按职责命名的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:Extract variable/method/function These shortcuts (see Table 7-9) help you to easily execute common refactoring techniques that will make your code more readable and maintainable. “Extract method” sounds like a complicated phrase, but it’s actually a simple practice of, well, extracting a code fragment (it can be a line or a block) into a function or method with a sensible name that describes the purpose of