Skip to Content
先整理?
book

先整理?

by Kent Beck
May 2025
Intermediate to advanced
124 pages
1h 7m
Chinese
O'Reilly Media, Inc.
Content preview from 先整理?

第 20 章 解开纠结

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

您正在更改某些代码的行为。你发现 Tidy 会让更改变得更容易。你进行了 Tidy。然后,你又写了一个测试用例。现在,你需要再修改一些行为。这导致了更多的 Tidy。一小时后,你

  • 切实了解需要做出的所有行为改变

  • 其实了解所有的 Tidy 都能缓解这些行为变化

  • 整理和更改工作一团糟,纠缠在一起

你至少有三种选择,但都不具吸引力:

  • 按原样发货。这样做对审稿人不礼貌,而且容易出错,但速度很快。

  • 将 Tidy 和改动分解成不同的 PR,或一系列 PR,或一个 PR 中的一系列提交。这样做更礼貌,但也很费事。

  • 丢弃正在进行的工作,重新开始,先做 Tidy。这样做工作量会更大,但会留下一个连贯的提交链。

沉没成本谬误使在这些选项中做出选择变得更加复杂。你有一些新的测试。它们通过了。为什么要放弃呢?

答案一如既往,因为你不仅仅是在指导计算机,而是在向其他人解释你对计算机的意图。指导计算机的最短路径并不是一个有趣的最终目标。

在本书的这一部分,我鼓励你尝试最后一个选项,你可能不会感到惊讶。重新实施可以让你在重新实施的过程中看到新的东西,让你从同一套行为改变中榨取更多的价值。

解开一个毛线球,首先要注意到你有一个纠结。 你越早意识到需要解开,工作就越小(策略之间的决定就变得不那么重要)。当你刚开始有意识地整理时,不管是先整理还是后整理,你很可能会错过 "游弋着做出改变 "和 "哦,不,我都做了些什么?"之间的过渡。别担心。随着时间的推移,,你会越来越擅长安排整理和改动的顺序。

说到 "先或后",是时候谈谈时机问题了。

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

超越Vibe编程

超越Vibe编程

Addy Osmani
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉

Publisher Resources

ISBN: 9798341656949