知识卡片
坏代码示例会自我扩散
未经理解地复制现存代码,会把局部反模式当成项目范例并扩散。复制本身不是错误,风险在于没有核对新场景的约束和取舍。代码审查与及时偿还技术债可以阻断这种示范效应。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Principles of Software Architecture Modernization》第1章《What’s Wrong with Monoliths?》(源文件:`_epub-src/OPS/ch01.xhtml`,归一化正文 [41793:45923))
- 结论依据:原文把“破窗”类比用于坏代码被复制成为默认实践,同时明确复制本身并非错误。
- 原始内容:Where copying and pasting intersects with the Broken Windows theory is that once you have several poorly written or understood pieces of code, there is a good chance that bad code or bad behavior will be replicated because of engineers copying code. Suddenly, a piece of code that you know is an anti-pattern becomes the standard of the project because the team permitted the bad code to exist in the first place.