CHAPTER 1

软件工程:受控的变化之工程学科

Software Engineering: The Engineering Discipline of Controlled Change
CHAPTER 1

前提(Premise)。软件(software)是一种异常易变的表达性媒介(expressive medium)。对这种媒介进行工程化,意味着既要利用它可变的能力,又要让有重大后果的变化处于受控之下。

英文原文

Premise. Software is an unusually changeable expressive medium. Engineering that medium means exploiting its capacity for change while keeping consequential change under control.

定义 · 软件(Software)

软件是一种表达性媒介,其中行为被表示出来,供机器执行——既包括传统的基于指令的计算,也包括机器推理。

一个排序程序把行为表示为处理器执行的指令。一个编码智能体(coding agent)则以不同的方式表示某些行为:它的软件可能提供工具、语境、约束和目标,而由智能体来推理应采取哪些行动。两者都用软件来表示机器能够执行的行为。

英文原文

Software is an expressive medium in which behavior is represented for execution by machines, including through both conventional instruction-based computation and machine reasoning.

A sorting program represents behavior as instructions that a processor executes. A coding agent represents some behavior differently: its software may supply tools, context, constraints, and an objective while the agent reasons about which actions to take. Both use software to represent behavior that a machine can execute.

软件媒介的性质

每个工程学科都在其材料的可能与局限之内工作。混凝土能承受巨大的压荷载。钢材能以相对较小的结构构件提供强度。电子电路能以机械装置无法企及的速度处理信号。媒介的性质决定了工程师能建造什么、以及如何建造。软件是一种不同类型的媒介,具有几种不寻常的性质。

英文原文

Every engineering discipline works within the possibilities and limitations of its materials. Concrete can carry enormous compressive loads. Steel can provide strength with comparatively small structural members. Electronic circuits can process signals at speeds impossible for mechanical mechanisms. The properties of the medium shape what engineers can build and how they can build it. Software is a different kind of medium, with several unusual properties.

软件是可变的。软件系统的大部分内容无需制造新的物理制品即可改动。以代码表示的行为,往往可以比固定在硬件中的相应行为便宜得多地修改、测试和替换。这并不意味着每一次软件变更都很便宜。接口会积累用户,数据表示会积累数据,架构选择会约束后续工作,已部署的系统会获得依赖关系。但软件给予工程师异常广泛的决策范围,这些决策在初始构建之后仍可修正。

英文原文

Software is changeable. Much of a software system can be altered without manufacturing a new physical artifact. A behavior represented in code can often be modified, tested, and replaced far more cheaply than a corresponding behavior fixed into hardware. This does not make every software change cheap. Interfaces accumulate users, data representations accumulate data, architectural choices constrain later work, and deployed systems acquire dependencies. But software gives engineers an extraordinary range of decisions that can remain revisable after initial construction.

软件是可复制的。一旦实现存在,生产另一份副本几乎不花什么成本。创造第一个实例所需的工程努力,不必为第一百万个实例重复付出。因此,一个成功的软件设计能够以工程制品中罕见的规模被复制。

英文原文

Software is copyable. Once an implementation exists, producing another copy costs almost nothing. The engineering effort required to create the first instance need not be repeated for the millionth. A successful software design can therefore be replicated at a scale unusual among engineered artifacts.

软件是可迁移的。软件行为并不永久地束缚于它最初实现的那件特定物理对象。同一个程序常常可以被转移到另一台机器上、部署到另一个地点,或并入另一个工程系统。适当的接口与抽象能够把一种能力与它之下的大部分机器分离开来。

英文原文

Software is transferable. Software behavior is not permanently tied to the particular physical object on which it was first realized. The same program can often be transferred to another machine, deployed in another location, or incorporated into another engineered system. Appropriate interfaces and abstractions can separate a capability from much of the machinery underneath it.

软件是可更新的。工程可以在部署之后继续进行。一个已经投入使用的系统可以获得新的行为、新的规则、修复的缺陷,或对发布时并不存在的环境的适应。因此,部署未必是构建的终点,它可以是持续工程过程中的一个节点。

英文原文

Software is updateable. Engineering can continue after deployment. A system already in use can receive new behavior, new rules, repaired defects, or adaptations to circumstances that did not exist when it was released. Deployment is therefore not necessarily the end of construction. It can be one point in a continuing engineering process.

这些性质彼此强化。软件可以被广泛复制,然后再更新;可以被转移到新环境并加以适应;一种能力可以在工程师继续修改其实现的同时保持在役。结果是一种异常适合必须变化的系统的媒介。

英文原文

These properties reinforce one another. Software can be copied widely and then updated. It can be transferred to new environments and adapted to them. A capability can remain in service while engineers continue to modify its realization. The result is a medium unusually suited to systems that must change.

我们把变化放进软件

现代工程系统包含一些应当保持稳定的决策,也包含一些我们预期会重新审视的决策。凡有选择之处,后一类决策正越来越多地迁移到软件中。

英文原文

Modern engineered systems contain some decisions that should remain stable and others that we expect to revisit. Where engineers have a choice, the latter increasingly migrate toward software.

以汽车为例。它的物理尺寸在出厂后无法远程改变。但软件可以改变动力系统如何响应驾驶员输入、电池如何管理、显示什么信息,或驾驶辅助功能如何表现。一台工业机器的物理结构可能打算使用几十年,而它的控制逻辑却随产品与运行条件而变化。通信基础设施、飞机、医疗设备、科学仪器和能源系统也同样把相对稳定的物理机器与提供可适应行为的软件结合起来。

英文原文

Consider an automobile. Its physical dimensions cannot be changed remotely after it leaves the factory. But software can alter how the powertrain responds to driver input, how the battery is managed, what information is displayed, or how driver-assistance features behave. An industrial machine may have a physical structure intended to last for decades while its control logic changes with products and operating conditions. Communications infrastructure, aircraft, medical devices, scientific instruments, and energy systems similarly combine relatively stable physical machinery with software that supplies adaptable behavior.

软件还创造了几乎没有可见物理对应物的工程系统:搜索引擎、金融系统、社交网络、操作系统、数据库、业务应用和云服务。它们的用途差异极大,但都利用了同一个基本性质:以软件表示的行为,可以随着需求与环境的变化而修正。

英文原文

Software also creates engineered systems with almost no visible physical counterpart: search engines, financial systems, social networks, operating systems, databases, business applications, and cloud services. Their purposes differ enormously, but they exploit the same basic property. Behavior represented in software can be revised as needs and circumstances change.

因此,软件工程(software engineering)不仅仅是生产程序的工程学科。它日益成为其他领域借以使其工程系统中某些部分变得可适应的学科。我们把行为放进软件,部分原因正是我们预期那种行为会变化。

英文原文

Software engineering is therefore not merely the engineering discipline for producing programs. It is increasingly the discipline through which other fields make parts of their own engineered systems adaptable. We put behavior in software partly because we expect that behavior to change.

但软件并非只变化一次。系统在使用期间,需求、用户、依赖、平台、法规以及负责它的工程师都在变化。当初创建系统时合理的决策,最终可能成为维护它的人眼中的约束、负担,甚至谜团。

英文原文

But software does not change once. Systems remain in use while requirements, users, dependencies, platforms, regulations, and the engineers responsible for them change. Decisions that were sensible when a system was created may eventually become constraints, liabilities, or simply mysteries to the people maintaining it.

因此,工程问题不仅仅是一次性生产出一个可接受的制品,而是要让一个制品在其自身与环境都在变化的情况下持续保持可接受。

英文原文

The engineering problem is therefore not merely to produce an acceptable artifact once. It is to keep an artifact acceptable as both the artifact and its environment change.

软件给予工程师不寻常的杠杆

软件的可复制性还有另一个后果:一个工程决策可以影响极其众多的人。大多数物理工程受到能够建造或修改的制品数量的约束。一位土木工程师可以就一座桥做出有重大后果的决策,但改变那座桥并不会自动改变世界上所有其他的桥。制造业可以大规模复制一个物理设计,但每多一件制品仍需材料、生产、运输和安装。

英文原文

Software's copyability has another consequence: a single engineering decision can affect an extraordinary number of people. Most physical engineering is constrained by the number of artifacts that can be built or modified. A civil engineer can make a consequential decision about a bridge, but changing that bridge does not automatically change every other bridge in the world. Manufacturing can replicate a physical design at scale, but doing so still requires material, production, transportation, and installation for each additional artifact.

软件的表现不同。一旦做出变更,传播它的成本与创造它的成本相比可能微不足道。一位工程师可以修改一个代码库,并通过一次更新或部署,改变运行在数百万乃至数十亿台设备上的软件。对一项云服务的变更可以一次性影响其全部用户群体。因此,个体工程决策与其对世界的影响之间的距离可以异常之短。

英文原文

Software behaves differently. Once a change has been made, the cost of propagating it can be tiny compared with the cost of creating it. An engineer can modify one codebase and, through an update or deployment, alter software running on millions or even billions of devices. A change to a cloud service can affect its entire user population at once. The distance between an individual engineering decision and its effects on the world can therefore be remarkably short.

注 · 软件工程具有不寻常的杠杆作用

软件工程师不必亲自建造一百万件制品,就能影响一百万个系统。可复制性与可更新性使一个工程决策得以在整个已部署群体中被复制。

英文原文

A software engineer need not personally construct a million artifacts to affect a million systems. Copyability and updateability allow one engineering decision to be reproduced across the entire deployed population.

这种杠杆作用是软件工程即使在制品本身看似无形时也承担重大责任的原因之一。一个小团队,有时甚至是一位工程师,就能做出后果堪比庞大物理工程的决策。让有益的修复抵达每一个已部署实例的同一机制,也能以同样的效率传播缺陷、漏洞或错误的假设。

英文原文

This leverage is one reason software engineering carries substantial responsibility even when the artifact itself seems intangible. A small team, or sometimes a single engineer, can make decisions whose consequences rival those of enormous physical engineering efforts. The same mechanism that lets a beneficial repair reach every deployed instance can propagate a defect, vulnerability, or mistaken assumption just as efficiently.

变化带来风险

一个容易改变的系统,也容易被错误地改变。新功能可能违反旧需求;一个组件中的修复可能破坏另一个组件所依赖的假设;一个看似无害的依赖可能损害安全边界;一种新的数据表示可能使旧数据无法读取;一次性能优化可能削弱可靠性;一次库更新可能改变整个系统的行为。解决今天问题的工程师,可能无意中摧毁多年前为他已不再知晓的理由而做出的决策。

英文原文

A system that is easy to change is also easy to change incorrectly. A new feature can violate an old requirement. A repair in one component can break an assumption made by another. An apparently harmless dependency can undermine a security boundary. A new data representation can make old data unreadable. A performance optimization can weaken reliability. A library update can alter behavior throughout a system. An engineer solving today's problem can unintentionally destroy a decision made years earlier for reasons the engineer no longer knows.

软件被复制得越广泛,有缺陷的变更就能传播得越远。软件的互联程度越高,局部变更在别处可能产生的后果就越多。软件更新得越频繁,系统暴露于非预期变更可能性的次数就越多。

英文原文

The more widely software is copied, the farther a defective change can propagate. The more interconnected software becomes, the more consequences a local change can have elsewhere. The more frequently software is updated, the more often the system is exposed to the possibility of unintended change.

这在软件工程的中心制造了一种张力。我们希望软件保持易变,因为可变性是它最大的优点之一。但我们也需要重要的性质在这些变化中存续下来。

英文原文

This creates a tension at the center of software engineering. We want software to remain easy to change because changeability is one of its greatest advantages. But we also need important properties to survive those changes.

因此,问题是一个工程控制(engineering control)的问题。

英文原文

The problem is therefore one of engineering control.

定义 · 工程(Engineering)

工程(engineering)是一门学科:对有重大后果的系统行使知情的控制,并为其结果承担责任。工程师不必亲自执行实现一个系统所需的每一项行动,但必须保持足够的掌控,以理解并指挥它、评估其重大性质的证据、在其假设失效时识别出来,并在必要时进行干预。他们对其职权之下做出的重大决策仍然负责。

——《基于模型的智能体工程》(Model-Based Agentic Engineering,Davis 2026)

负责一个支付服务的工程师不必编写每一个组件,也不必亲自操作每一台服务器。但该工程师仍然必须能够指挥系统的开发、判断证据是否足以信任它、在关于依赖或运行条件的假设失效时识别出来,并在必要时进行干预。

英文原文

Engineering is the discipline of exercising informed control over consequential systems and accepting responsibility for their outcomes. Engineers need not personally perform every act required to realize a system. They must retain sufficient command to understand and direct it, evaluate the evidence for its consequential properties, recognize when its assumptions fail, and intervene when necessary. They remain answerable for the consequential decisions made under their authority.

— Model-Based Agentic Engineering (Davis 2026)

An engineer responsible for a payment service need not write every component or personally operate every server. The engineer must nevertheless be able to direct the system's development, judge whether the evidence justifies trusting it, recognize when assumptions about dependencies or operating conditions fail, and intervene when necessary.

软件异常的可变能力造成了对工程控制的需求。这种媒介使有重大后果的行为异常容易被改动和传播;而工程要求这些后果始终处于知情的控制与责任之下。

英文原文

Software's unusual capacity for change creates the need for engineering control. The medium makes consequential behavior unusually easy to alter and propagate; engineering requires that those consequences remain subject to informed control and responsibility.

定义 · 软件工程(Software engineering)

软件工程是关于软件系统中受控的变化(controlled change)的工程学科。它创建并演进软件,同时对那些重要的性质与后果保持足够的控制。

假设支付服务必须增加一种新的支付方式。编写实现该方式的代码只是问题的一部分。这一变更还必须保留现有的安全性质、与客户端和已存储的数据保持兼容,并提供足以证明部署合理的证据。软件使行为变得可变;工程则使该变化的后果处于受控之下。

英文原文

Software engineering is the engineering discipline of controlled change in software systems. It creates and evolves software while preserving sufficient control over the properties and consequences that matter.

Suppose the payment service must add a new payment method. Producing code that implements the method is only part of the problem. The change must also preserve existing security properties, remain compatible with clients and stored data, and provide enough evidence to justify deployment. Software makes the behavior changeable; engineering keeps the consequences of that change under control.

受控的变化并不意味着阻止变化,也不要求工程师亲自决定每一个细节。软件工程利用媒介提供的自由,同时保持足够的控制,以确定什么应当改变、什么必须保持为真、需要什么证据,以及何时必须重新审视早先的决策或假设。

英文原文

Controlled change does not mean preventing change. Nor does it require engineers to determine every detail themselves. Software engineering exploits the freedom the medium provides while maintaining sufficient control to determine what should change, what must remain true, what evidence is needed, and when an earlier decision or assumption must be reconsidered.

接下来的章节将考察这一问题的不同部分。需求工程(requirements engineering)问:哪些结果重要到足以成为工程承诺。规约(specification)确定这些承诺的含义精确到足以约束可接受的实现(acceptable realizations)。架构(architecture)组织一个系统,使其各项义务能够共存,并且使预期的变化无需一次性推理全部内容。设计(design)解决在这种组织之内余下的选择。验证(validation)问:什么样的证据足以相信所得系统是可接受的。维护与演进则在系统及其环境变化的过程中继续这一过程。而软件过程——我们接下来要转向的主题——问的是如何组织所有这些工作。

英文原文

The chapters that follow examine different parts of that problem. Requirements engineering asks what outcomes matter enough to become engineering commitments. Specification determines what those commitments mean precisely enough to constrain acceptable realizations. Architecture organizes a system so that its obligations can coexist and so that expected changes do not require reasoning about everything at once. Design resolves the choices that remain within that organization. Validation asks what evidence justifies believing that the resulting system is acceptable. Maintenance and evolution continue the process as the system and its environment change. Software process, to which we turn next, asks how to organize all of this work.

技术移动了瓶颈

工程师必须控制的东西保持不变,但行使这种控制的成本随技术而变化。新技术使曾经昂贵的能力变得相对丰富,工程则围绕仍然存在的约束重新组织。

英文原文

What engineers must control remains, but the cost of exercising that control changes with technology. New technologies make capabilities that were once expensive comparatively abundant, and engineering reorganizes around the constraints that remain.

蒸汽机以人力与畜力无法提供的规模提供了机械动力。工厂极大地扩展了物理生产。集成电路使计算变得异常廉价。这些发展并未消除工程,而是改变了它的经济学。当一种能力变得丰富时,系统其他地方的问题就变得相对更重要:控制这种新能力、协调它的使用,以及决定用它做什么。

英文原文

The steam engine made mechanical power available at a scale that human and animal labor could not provide. Factories greatly expanded physical production. Integrated circuits made computation extraordinarily inexpensive. These developments did not eliminate engineering. They changed its economics. As one capability became abundant, problems elsewhere in the system became relatively more important: controlling the new capability, coordinating its use, and deciding what to do with it.

软件本身也反复经历了同样的过程。高级语言使程序员较少直接负责机器指令;操作系统与程序库提供了曾经必须就地构建的能力;开源生态使大量可复用的实现唾手可得;云平台使计算基础设施按需可用。每一次发展都改变了工程师必须亲自做的事情,同时也产生了关于如何选择、组合、控制与信任由此得到的能力的新决策。

英文原文

Software itself has repeatedly undergone the same process. Higher-level languages made programmers less responsible for machine instructions. Operating systems and libraries supplied capabilities that once had to be constructed locally. Open-source ecosystems made enormous bodies of implementation available for reuse. Cloud platforms made computing infrastructure available on demand. Each development changed what engineers had to do themselves, while creating new decisions about how the resulting capabilities should be selected, combined, controlled, and trusted.

生成式人工智能(generative AI)与编码智能体延续了这一进程。曾经需要大量人力才能完成实现工作,如今越来越多地可以由机器生成、转换、测试或探索。因此,重要的问题不是工程师是否亲自键入了最终的代码——工程从来不是以亲自执行实现一个系统所需的每一项行动来定义的。问题在于工程师是否保留了足够的控制,以指挥这项工作、判断其后果、评估重要性质的证据,并在必要时进行干预。

英文原文

Generative AI and coding agents continue that progression. Implementation that once required substantial human effort can increasingly be generated, transformed, tested, or explored by machine. The important question is therefore not whether an engineer personally typed the resulting code. Engineering has never been defined by personally performing every act required to realize a system. The question is whether engineers retain sufficient control to direct the work, judge its consequences, evaluate the evidence for the properties that matter, and intervene when necessary.

因此,更强的实现能力并不会使软件工程过时。如果实现变得更便宜,那么决定建造什么、控制什么可以改变、保留什么必须为真、以及判断结果是否可接受,就成为工程问题中更大的部分。瓶颈移动了。

英文原文

Greater implementation capacity therefore does not make software engineering obsolete. If implementation becomes cheaper, deciding what to build, controlling what may change, preserving what must remain true, and determining whether the result is acceptable become a larger fraction of the engineering problem. The bottleneck moves.

工具将继续变化,我们用它们建造的系统也将继续变化。持久的问题是:如何学会利用一种为变化而生的媒介,同时不放弃对这些变化意味着什么的控制。

英文原文

The tools will continue to change. So will the systems we build with them. The enduring problem is learning how to exploit a medium built for change without surrendering control of what those changes mean.

为决策而度量

工程师如何知道自己是否正在失去这种控制?软件的可变性只有在工程师保留足够控制、能够有意识地运用它时,才会产生杠杆作用,而对于任何一个具体系统而言,这一说法并非不证自明。变化本身会留下可观察的后果,因此工程师可以检验关于系统实际仍有多可控的假设。

英文原文

How would engineers know whether they were losing that control? The changeability of software produces leverage only when engineers retain enough control to use it deliberately, and that claim is not self-evidently true of any particular system. Change itself leaves observable consequences, so engineers can test their assumptions about how controllable a system actually remains.

哪些观察有帮助,取决于手头的决策。工程师可以考察一项有重大后果的变更到达用户需要多长时间、变更需要返工的频率、一次修改在系统中传播的范围、变更引入故障的频率,或获得变更可接受的证据需要多长时间。这些观察涉及不同的性质。变更前置时间(change lead time)说明系统容纳变更的能力;逃逸缺陷(escaped defects)说明伴随变更的风险;一次典型变更触及的组件数量可能为耦合程度提供证据。其中任何一项都不是对工程质量的一般性度量,把其中任何一项当作一般性度量,就会用一个恰好可得的数字取代工程问题本身。

英文原文

Which observations help depends on the decision at hand. Engineers might examine how long a consequential change takes to reach users, how often changes require rework, how widely a modification propagates through the system, how frequently changes introduce failures, or how long it takes to obtain evidence that a change is acceptable. These observations concern different properties. Change lead time says something about the system's capacity to accommodate change; escaped defects say something about the risk accompanying it; the number of components a typical change touches may provide evidence about coupling. None of them measures engineering quality in general, and treating any one as if it did would replace the engineering question with a number that happens to be available.

更深层的问题是:媒介是否继续提供工程模型所预测的杠杆作用。一个本应保持易变的系统,如果其修改变得越来越广泛、越来越有风险或越来越昂贵,就是在提供证据,说明其结构已不再支撑这一意图。度量的目的不是数字本身,而是尽早让这种偏差变得可见,使工程师能够重新审视支配变化的结构与实践,而不是在最需要控制的时候才发现控制已经丧失。

英文原文

The deeper question is whether the medium continues to supply the leverage the engineering model predicts. A system intended to remain readily changeable, but whose modifications become steadily broader, riskier, or more expensive, is supplying evidence that its structure no longer supports that intention. The purpose of the measurement is not the number. It is to make the discrepancy visible early enough that engineers can reconsider the structures and practices governing change, rather than discovering the loss of control at the moment they most need it.

小结

软件是一种表达性媒介,其中行为被表示出来供机器执行。它的可变性、可复制性、可迁移性与可更新性之所以宝贵,正是因为工程师可以在系统创建之后继续改变行为。这些同样的性质也赋予个别变更不寻常的覆盖范围,并使错误、漏洞与错误的假设与改进一样容易传播。

英文原文

Software is an expressive medium in which behavior is represented for execution by machines. Its unusual changeability, copyability, transferability, and updateability make it valuable precisely because engineers can continue to alter behavior after a system has been created. Those same properties give individual changes unusual reach and allow mistakes, vulnerabilities, and mistaken assumptions to propagate just as readily as improvements.

工程要求对有重大后果的系统进行知情的控制,并为其结果承担责任。软件工程把这一责任应用于一种为变化而生的媒介。它的中心问题是受控的变化(controlled change):在利用软件适应性的同时,对那些重要的性质与后果保持足够的控制。

英文原文

Engineering requires informed control over consequential systems and responsibility for their outcomes. Software engineering applies that responsibility to a medium built for change. Its central problem is controlled change: exploiting software's adaptability while preserving sufficient control over the properties and consequences that matter.

生成式人工智能等技术可以大幅降低生产实现的成本,但并不能消除这一问题。随着实现变得更加丰富,关于建造什么、什么可以改变、什么必须保持为真、以及什么证据才算充分的工程判断(engineering judgment),在工程工作中占据更大的份额。

英文原文

Technologies such as generative AI can radically reduce the cost of producing implementations, but they do not remove this problem. As implementation becomes more abundant, judgment about what to build, what may change, what must remain true, and what evidence is sufficient becomes a larger share of the engineering work.

延伸阅读

  • Davis, James C. Model-Based Agentic Engineering. 1st ed. 2026. https://davisjam.github.io/model-based-agentic-software-engineering/book/mage-book/index.html —— 发展了一套理论,用于在能力日益强大的智能体承担越来越多工作时维持工程控制。
  • Brooks, Frederick P. “No Silver Bullet: Essence and Accidents of Software Engineering.” Computer 20, no. 4 (1987): 10–19. —— 关于软件的本质困难与实现的偶然困难的经典区分。

本译本为非官方译本,仅供个人学习使用。原文版权归 James C. Davis 所有。