Skip to Content
先整理?
book

先整理?

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

第 18 章 批量大小 批量大小

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

在集成和部署之前,应该做多少 Tidy 工作?

这有几个方面的考虑:

  • 你需要做多少 Tidy?也就是说,如果我们把 "整理 "定义为支持下一个行为改变的结构性改变,那么你需要做多少结构性改变才能支持下一个行为改变呢?Tidyying 并不是着眼于遥远的未来。Tidy 整理是为了满足眼前的需要。(我们将在第 21 章讨论 "先做/后做/再做 "时进一步讨论这个问题)。

  • Tidy 多容易集成和部署?

第 16 章中,我讨论了不要把整理和行为改变混在一起。但是,我们仍然有一个悬而未决的问题,那就是到底是把所有的 Tidy 整理工作放在一起批处理,还是分别进行,抑或是介于两者之间(图 18-1)。

tifi 1801
图 18-1. 结构更改分批或单独进行

这让我们陷入了一个权衡空间,也被 称为 "金发女郎困境"。有哪些竞争成本可以让我们评估什么是每批理货次数太少、太多,以及每批理货次数恰到好处的范围(图 18-2)?

tifi 1802
图 18-2. 每批 Tidy 的权衡空间

图 18-3显示了当我们在一个批次中放入更多 Tidy 时,。

tifi 1803
图 18-3. 随着批次增加而增加的成本

其中包括

碰撞

每批整理的次数越多,整合前的延迟时间就越长,整理工作与别人正在做的工作发生冲突的几率也就越大。一旦遇到合并冲突,我们合并工作的成本就会上升一个数量级。(请记住,所有这些 "数字 "都只是方向性的精确数字,只是为了帮助训练你的直觉)。

互动

同样,批次意外改变行为的几率也会随着批次中 Tidy 的数量而上升。同样,当我们发生交互时,合并成本也会大幅上升。

猜测

我知道我们说过,我们整理的东西只够支持下一次行为改变,但是是的。每批整理的次数越多,我们就越容易只因为整理而整理,由此产生的额外成本也就越多。

所有这些因素都减少了我们在集成和部署(这是一回事,对吗?)之前想要的批量整理的数量。然而,我在野外看到了大批量的 Tidy。这到底是怎么回事?请看图 18-4

tifi 1804
图 18-4. 审查成本随着批量缩小而上升

在许多组织中,通过审查和部署完成一项变更的固定成本非常高。程序员感受到了这一成本,因此他们会在权衡空间内进行右移,即使碰撞、交互和投机的成本在上升。

怎么办,怎么办?

有些人认为这些成本曲线是刻在石碑上的,是我们所处的开发宇宙的物理定律。不是的。 如果我们想降低 Tidy 的成本,从而增加 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