← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1971.o.1.b.1.a.2.a.1.b.8.f

任务驱动重构要追到核心根因

理解等级:高级

面对结构混乱的大系统,只修当前任务最痛处,可能反复处理外围症状,回避核心领域的严重纠结,使后续重构更难。原书建议在任务驱动重构中先判断根因是否落在核心领域,或核心与支持元素的关系上;若是,就优先修复那处结构,而不只补任务边缘。

“从哪里痛就改哪里”可作为发现问题的入口,但是否扩大修改范围,要看它是否触及核心根因。这个取舍并不要求一次重构整个系统。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第126章《Choosing Refactoring Targets》(源文件:_epub-src/0321125215_ch15lev1sec10.html;单元01) - 结论依据:原文批评只按当前任务修外围症状,并明确要求在任务驱动重构时优先处理核心或核心与支持元素关系的根因。 - 原始内容:I don't hold with either of these. The first is impractical except in a few projects staffed entirely with top programmers. The second tends to pick around the edges, treating symptoms and ignoring root causes, shying away from the worst tangles. Eventually the code becomes harder and harder to refactor. [...] In a pain-driven refactoring, you look to see if the root involves the CORE DOMAIN or the relationship of the CORE to a supporting element. If it does, you bite the bullet and fix that first. - 转录说明:`[...]` 标明中间的设问省略;原文术语为 `pain-driven refactoring`,卡片以“任务驱动”指其所举“为完成当前任务而从痛处开始”的情境。