From 67af68c5a4196671478e8d8fc21ead45aa8dbde6 Mon Sep 17 00:00:00 2001 From: qiangmzsx Date: Mon, 5 Aug 2024 16:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=83=E7=AB=A0=E5=92=8C=E7=AC=AC?= =?UTF-8?q?=E5=85=AB=E7=AB=A0=E7=BA=A0=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- _sidebar.md | 2 +- .../Chapter-6_Leading_at_Scale.md | 2 +- ...apter-7_Measuring_Engineering_Productivity.md | 10 +++++----- .../Chapter-8_Style_Guides_and_Rules.md | 16 ++++++++-------- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 78d09b8..8390002 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ https://qiangmzsx.github.io/Software-Engineering-at-Google/#/ | | | chapter 5 : How to Lead a Team | [第五章:如何领导团队](./zh-cn/Chapter-5_How_to_Lead_a_Team/Chapter-5_How_to_Lead_a_Team.md) | 完成校验 | @qiangmzsx | 2022-05-02 | | | | | chapter 6 : Leading at Scale | [第六章:规模优先](./zh-cn/Chapter-6_Leading_at_Scale/Chapter-6_Leading_at_Scale.md) | 完成校验 | @FingerLiu | 2022-04-06 | | | | | chapter 7 : Measuring Engineering Productivity | [第七章:测量工程效率](./zh-cn/Chapter-7_Measuring_Engineering_Productivity/Chapter-7_Measuring_Engineering_Productivity.md) | 完成校验 | @qiangmzsx | 2022-05-23 | | -| PART 3 Processes | 第三部分 流程 | chapter 8 : Style Guides and Rules | [第八章:风格指导和规则](./zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md) | 完成校验 | @ll13 | 2022-04-18 | | +| PART 3 Processes | 第三部分 流程 | chapter 8 : Style Guides and Rules | [第八章:风格指南和规则](./zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md) | 完成校验 | @ll13 | 2022-04-18 | | | | | chapter 9 : Code Review | [第九章:代码审查](./zh-cn/Chapter-9_Code_Review/Chapter-9_Code_Review.md) | 完成校验 | @qiangmzsx | 2022-04-04 | | | | | chapter 10 : Documentation | [第十章:文档](./zh-cn/Chapter-10_Documentation/Chapter-10_Documentatio.md) | 完成校验 | @qiangmzsx | 2022-01-15 | 1、概述,大略地叙述,对文章或事物进行概括表达。在百度百科里,特指词条概述,对已有信息进行简明归纳。
2、概念:人类在认识过程中,从感性认识上升到理性认识,把所感知的事物的共同本质特点抽象出来,加以概括,是自我认知意识的一种表达,形成概念式思维惯性。在人类所认知的思维体系中最基本的构筑单位。 | | | | chapter 11 : Testing Overview | [第十一章:测试概述](./zh-cn/Chapter-11_Testing_Overview/Chapter-11_Testing_Overview.md) | 完成校验 | @qiangmzsx | 2022-04-15 | | diff --git a/_sidebar.md b/_sidebar.md index f9aa70a..b9075dc 100644 --- a/_sidebar.md +++ b/_sidebar.md @@ -7,7 +7,7 @@ - [第五章 如何领导团队](zh-cn/Chapter-5_How_to_Lead_a_Team/Chapter-5_How_to_Lead_a_Team.md) - [第六章 规模优先](zh-cn/Chapter-6_Leading_at_Scale/Chapter-6_Leading_at_Scale.md) - [第七章 测量工程效率](zh-cn/Chapter-7_Measuring_Engineering_Productivity/Chapter-7_Measuring_Engineering_Productivity.md) -- [第八章 风格指导和规则](zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md) +- [第八章 风格指南和规则](zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md) - [第九章 代码审查](zh-cn/Chapter-9_Code_Review/Chapter-9_Code_Review.md) - [第十章 文档](zh-cn/Chapter-10_Documentation/Chapter-10_Documentatio.md) - [第十一章 测试概述](zh-cn/Chapter-11_Testing_Overview/Chapter-11_Testing_Overview.md) diff --git a/zh-cn/Chapter-6_Leading_at_Scale/Chapter-6_Leading_at_Scale.md b/zh-cn/Chapter-6_Leading_at_Scale/Chapter-6_Leading_at_Scale.md index b101e85..7d1c623 100644 --- a/zh-cn/Chapter-6_Leading_at_Scale/Chapter-6_Leading_at_Scale.md +++ b/zh-cn/Chapter-6_Leading_at_Scale/Chapter-6_Leading_at_Scale.md @@ -428,7 +428,7 @@ Successful leaders naturally take on more responsibility as they progress (and t ## TL;DRs 内容提要 - Always Be Deciding: Ambiguous problems have no magic answer; they’re all about finding the right trade-offs of the moment, and iterating. -- Always Be Leaving: Your job, as a leader, is to build an organization that automatically solves a class of ambiguous problems—over time—without you needing to be present. +- Always Be Leaving: Your job, as a leader, is to build an organization that automatically solves a class of ambiguous problems—over time—without you needing to be present. - Always Be Scaling: Success generates more responsibility over time, and you must proactively manage the scaling of this work in order to protect your scarce resources of personal time, attention, and energy. - 始终保持决断力:模糊的问题没有灵丹妙药;他们都是关于找到当下最佳的权衡,然后反复迭代。 diff --git a/zh-cn/Chapter-7_Measuring_Engineering_Productivity/Chapter-7_Measuring_Engineering_Productivity.md b/zh-cn/Chapter-7_Measuring_Engineering_Productivity/Chapter-7_Measuring_Engineering_Productivity.md index dc13039..51e5e74 100644 --- a/zh-cn/Chapter-7_Measuring_Engineering_Productivity/Chapter-7_Measuring_Engineering_Productivity.md +++ b/zh-cn/Chapter-7_Measuring_Engineering_Productivity/Chapter-7_Measuring_Engineering_Productivity.md @@ -11,7 +11,7 @@ Google is a data-driven company. We back up most of our products and design decisions with hard data. The culture of data-driven decision making, using appropriate metrics, has some drawbacks, but overall, relying on data tends to make most decisions objective rather than subjective, which is often a good thing. Collecting and analyzing data on the human side of things, however, has its own challenges. Specifically, within software engineering, Google has found that having a team of specialists focus on engineering productivity itself to be very valuable and important as the company scales and can leverage insights from such a team. -谷歌是一家数据驱动型公司。我们的大部分产品和设计决策都有可靠的数据支持。数据驱动的决策文化,使用适当的指标,有一些不足,但总的来说,依靠数据往往使大多数决策变得客观而不是主观,这往往是一件好事。然而,收集和分析数据是人性的弱点,有其自身的挑战。具体来说,在软件工程领域,谷歌发现,随着公司规模的扩大,拥有一支专注于工程生产效率的专家团队本身是非常有价值和重要的,可以利用这样一支团队的洞察力。 +谷歌是一家数据驱动型公司。我们的大部分产品和设计决策都有可靠的数据支持。数据驱动决策的文化,使用适当的指标,有一些不足,但总的来说,依靠数据往往使大多数决策变得客观而不是主观,这往往是一件好事。然而,收集和分析数据是人性的弱点,有其自身的挑战。具体来说,在软件工程领域,谷歌发现,随着公司规模的扩大,拥有一支专注于工程生产效率的专家团队本身是非常有价值和重要的,可以利用这样一支团队的洞察力。 ## Why Should We Measure Engineering Productivity? 我们为什么要度量工程效率 @@ -55,7 +55,7 @@ Before we decide how to measure the productivity of engineers, we need to know w At Google, we’ve come up with a series of questions to help teams determine whether it’s even worth measuring productivity in the first place. We first ask people to describe what they want to measure in the form of a concrete question; we find that the more concrete people can make this question, the more likely they are to derive benefit from the process. When the readability team approached us, its question was simple: are the costs of an engineer going through the readability process worth the benefits they might be deriving for the company? -在谷歌,我们想出了一系列的问题来帮助团队确定是否值得优先度量生产效率。我们首先要求人们以具体问题的形式描述他们想要度量的东西;我们发现,人们提出这个问题越具体,他们就越有可能从这个过程中获益。当可读性团队与我们接触时,其问题很简单:工程师在提高可读性过程中的成本增加是否匹配他们为公司带来的好处? +在谷歌,我们想出了一系列的问题来帮助团队判定是否值得优先度量生产效率。我们首先要求人们以具体问题的形式描述他们想要度量的东西;我们发现,人们提出这个问题越具体,他们就越有可能从这个过程中获益。当可读性团队与我们接触时,其问题很简单:工程师在提高可读性过程中的成本增加是否匹配他们为公司带来的好处? We then ask them to consider the following aspects of their question: @@ -91,7 +91,7 @@ We then ask them to consider the following aspects of their question: *谁将决定对结果采取行动,以及他们何时采取行动?* 我们这样问是为了确保要求度量的人是被授权采取行动的人(或直接代表他们采取行动)。归根结底,度量我们的软件流程的目的是帮助人们做出业务决策。了解这个人是谁很重要,包括什么形式的数据能说服他们。尽管最好的研究包括各种方法(从结构化访谈到日志的统计分析等各种方法),但为决策者提供他们需要的数据的时间可能有限。在这些情况下,最好的办法是迎合决策者的要求。他们是否倾向于通过访谈中可以获取到的故事来做出决策?他们是否信任调查结果或日志数据?他们对复杂的统计分析感到满意吗?如果决策者压根就不相信结果的形式,那么度量过程又没有意义。 - 在可读性方面,我们对每种编程语言都有一个明确的决策者。有两个语言团队,即Java和C++,积极向我们寻求帮助,而其他团队则在等待,看这些语言先发生什么。决策者相信工程师自我报告的经验,以了解快乐和学习,但决策者希望看到基于日志数据的速度和代码质量的 "硬数字"。这意味着,我们需要对这些指标进行定性和定量分析。这项工作没有一个硬性的截止日期,但有一个内部会议,如果有变化的话,这个会议将宣布一个新的时间点。这个期限给了我们几个月的时间来完成这项工作。 + 在可读性方面,我们对每种编程语言都有一个明确的决策者。有两个语言团队,即Java和C++,积极向我们寻求帮助,而其他团队则在等待,看这些语言先发生什么。决策者相信工程师自我报告的经验,以了解快乐和学习,但决策者希望看到基于日志数据的速度和代码质量的 "硬数字"。这意味着,我们需要对这些指标进行定性和定量分析。这项工作没有一个硬性的截止日期,但如果有变化,有一个内部会议可以用来适时地宣布变更。这个期限给了我们几个月的时间来完成这项工作。 By asking these questions, we find that in many cases, measurement is simply not worthwhile…and that’s OK! There are many good reasons to not measure the impact of a tool or process on productivity. Here are some examples that we’ve seen: @@ -122,7 +122,7 @@ By asking these questions, we find that in many cases, measurement is simply not *结果只能作为浮华的指标,以来支持你一定要做的事情* 这也许是我们在谷歌告诉人们不要度量软件过程的最常见的原因。很多时候,人们已经为多个原因规划了一个决策,而改进软件开发过程只是这些决策的一个好处。例如,谷歌的发布工具团队曾经要求对发布工作流程系统的计划变更进行度量。由于变化的性质,很明显,这个变化不会比目前的状态差,但他们不知道这是一个小的改进还是一个大的改进。我们问团队:如果结果只是一个小的改进,无论如何你会花资源来实现这个功能,即使它看起来不值得投资?答案是肯定的! 这个功能碰巧提高了生产效率,但这是一个副作用:它也更具有性能,降低了发布工具团队的维护负担。 -*唯一可用的指标不够精确,无法度量问题,而且会被其他因素所干扰* +*现有可用的度量标准不够精确,无法准确测量问题,且可能受到其他因素的干扰* 在某些情况下,所需的指标(见即将到来的关于如何识别指标的章节)根本无法获得。在这些情况下,使用其他不那么精确的指标(例如,编写的代码行)进行度量是很诱人的。然而,这些指标的任何结果都是无法解释的。如果这个指标证实了利益相关者预先存在的观念,他们最终可能会继续执行他们的计划,而不考虑这个指标不是一个准确的度量标准。如果它没有证实他们的观念,那么指标本身的不精确性就提供了一个简单的解释,利益相关者可能再次继续他们的计划。 When you are successful at measuring your software process, you aren’t setting out to prove a hypothesis correct or incorrect; *success means giving a stakeholder the data they need to make a decision*. If that stakeholder won’t use the data, the project is always a failure. We should only measure a software process when a concrete decision will be made based on the outcome. For the readability team, there was a clear decision to be made. If the metrics showed the process to be beneficial, they would publicize the result. If not, the process would be abolished. Most important, the readability team had the authority to make this decision. @@ -152,7 +152,7 @@ At Google, we use the Goals/Signals/Metrics (GSM) framework to guide metrics cre - A *metric* is proxy for a signal. It is the thing we actually can measure. It might not be the ideal measurement, but it is something that we believe is close enough. - *目标* 是一个期望的最终结果。它是根据你希望在高层次上理解的内容来表述的,不应包含对具体度量方法的引用。。 -- *信号* 是你如何知道你已经实现了最终结果。信号是我们*想要*度量的东西,但它们本身可能是不可度量的。 +- *信号* 是指你可能如何得知你已经达到最终结果的方式。信号是我们*想要*度量的东西,但它们本身可能是不可度量的。 - *指标* 是信号的代表。它是我们实际上可以度量的东西。它可能不是理想的度量,但它是我们认为足够接近的东西。 The GSM framework encourages several desirable properties when creating metrics. First, by creating goals first, then signals, and finally metrics, it prevents the *streetlight* *effect*. The term comes from the full phrase “looking for your keys under the streetlight”: if you look only where you can see, you might not be looking in the right place. With metrics, this occurs when we use the metrics that we have easily accessible and that are easy to measure, regardless of whether those metrics suit our needs. Instead, GSM forces us to think about which metrics will actually help us achieve our goals, rather than simply what we have readily available. diff --git a/zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md b/zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md index 660456a..0a4c8ac 100644 --- a/zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md +++ b/zh-cn/Chapter-8_Style_Guides_and_Rules/Chapter-8_Style_Guides_and_Rules.md @@ -2,7 +2,7 @@ # Style Guides and Rules -# 第八章 风格指导和规则 +# 第八章 风格指南和规则 **Written by Shaindel Schwartz** @@ -11,23 +11,23 @@ Most engineering organizations have rules governing their codebases—rules about where source files are stored, rules about the formatting of the code, rules about naming and patterns and exceptions and threads. Most software engineers are working within the bounds of a set of policies that control how they operate. At Google, to manage our codebase, we maintain a set of style guides that define our rules. -大多数软件工程机构都有管理其代码库的规则——关于源文件的存储位置、代码格式化规则、命名规则和模式以及异常和线程。大多数软件工程师就在这组控制他们如何运作的策略的范围内工作。在谷歌,要管理我们的代码库,我们维护了一套风格指南来定义我们的规则。 +大多数软件工程机构都有管理其代码库的规则——关于源文件的存储位置规则、代码格式化规则、命名规则和模式以及异常处理规则和多线程规则。大多数软件工程师就在这组控制他们如何运作的策略的范围内工作。在谷歌,要管理我们的代码库,我们维护了一套定义我们规则的风格指南。 Rules are laws. They are not just suggestions or recommendations, but strict, mandatory laws. As such, they are universally enforceable—rules may not be disregarded except as approved on a need-to-use basis. In contrast to rules, guidance provides recommendations and best practices. These bits are good to follow, even highly advisable to follow, but unlike rules, they usually have some room for variance. -规则就像法律。 它们不仅仅是建议或提议,而是严格的、强制性的法律。 因此,规则具有普遍可执行性——不得无视规则除非在需要使用的基础上获得豁免。 与规则相反,指导提供帮助建议和最佳实践。 指导值得遵循,甚至是高度建议能够遵守,但与规则不同的是,指导通常允许出现一些变化的空间。 +规则就像法律。 它们不仅仅是建议或提议,而是严格且强制性的法律。 因此,规则具有普遍可执行性——不得无视规则除非在需要使用的基础上获得豁免。 与规则相反,指导提供帮助建议和最佳实践。 指导值得遵循,甚至是高度建议能够遵守,但与规则不同的是,指导通常允许出现一些变化的空间。 We collect the rules that we define, the do’s and don’ts of writing code that must be followed, in our programming style guides, which are treated as canon. “Style” might be a bit of a misnomer here, implying a collection limited to formatting practices. Our style guides are more than that; they are the full set of conventions that govern our code. That’s not to say that our style guides are strictly prescriptive; style guide rules may call for judgement, such as the rule to use names that are “as descriptive as possible, within reason.” Rather, our style guides serve as the definitive source for the rules to which our engineers are held accountable. -我们把我们定义的规则,即写代码时必须遵守的 "做 "和 "不做",收集在我们的编程风格指南中,这些指南被视为典范。 “风格”可能这里有点名不副实,暗示着范围仅限于格式化实践。我们的风格指南不止于此; 它们是一套完整的约定约束我们的代码。 这并不是说我们的风格指南是严格规定的; 是指导还是规则可能需要判断,例如有一条命名规则是“[在合理范围内使用与描述性相同的名称。]” 并且,我们的风格指南是最终的来源我们的工程师必须遵守的规则。 +我们把我们定义的规则,即写代码时必须遵守的 "允许"和 "禁止",收集在我们的编程风格指南中,这些指南被视为典范。 “风格”可能这里有点名不副实,暗示着范围仅限于格式化实践。我们的风格指南不止于此; 它们是一套完整的约定约束我们的代码。 这并不是说我们的风格指南是严格规定的; 是指导还是规则可能需要判断,例如有一条命名规则是“[在合理范围内使用与描述性相同的名称。]” 并且,我们的风格指南是最终的来源我们的工程师必须遵守的规则。 We maintain separate style guides for each of the programming languages used at Google [^1].At a high level, all of the guides have similar goals, aiming to steer code development with an eye to sustainability. At the same time, there is a lot of variation among them in scope, length, and content. Programming languages have different strengths, different features, different priorities, and different historical paths to adoption within Google’s ever-evolving repositories of code. It is far more practical, therefore, to independently tailor each language’s guidelines. Some of our style guides are concise, focusing on a few overarching principles like naming and formatting, as demonstrated in our Dart, R, and Shell guides. Other style guides include far more detail, delving into specific language features and stretching into far lengthier documents—notably, our C++, Python, and Java guides. Some style guides put a premium on typical non-Google use of the language—our Go style guide is very short, adding just a few rules to a summary directive to adhere to the practices outlined in the externally recognized conventions. Others include rules that fundamentally differ from external norms; our C++ rules disallow use of exceptions, a language feature widely used outside of Google code. -我们为每一门在谷歌使用的编程语言都单独维护一套代码风格指南。在高层次上,所有指南都有相似的目标,旨在引导代码开发并着眼于可持续性。同时,也有很多变化其中包括范围、长度和内容。编程语言有不同的优势,不同的特点,不同的重点,以及在谷歌不断发展的代码库中采用的不同历史路径。因此,独立定制每种语言的指南要实际得多。我们的一部分风格指南注重简洁,专注于一些总体原则,如命名和格式,如在我们的 Dart、R 和 Shell 指南中进行演示的样子。另一部分风格指南注重更多细节方面,深入研究特定的语言特征并扩展内容,特别是我们的 C++、Python 和 Java 指南。还有一部分风格指南重视该语言在谷歌之外的惯例——我们的 Go 风格指南非常简短,只是在一个总结指令中添加了一些规则,以遵循外部公认的惯例。也有部分指南的规则和外部规范根本不同;我们的 C++ 风格指南中不允许使用异常,而使用异常是一种在 Google 代码之外广泛使用语言特性。 +我们为谷歌使用的每一门编程语言都单独维护了一套风格指南。在高层次上,所有指南都有相似的目标,旨在引导代码开发并着眼于可持续性。同时,也有很多变化其中包括范围、长度和内容。编程语言有不同的优势,不同的特点,不同的重点,以及在谷歌不断发展的代码库中采用的不同历史路径。因此,独立定制每种语言的指南要实际得多。我们的一部分风格指南注重简洁,专注于一些总体原则,如命名和格式,如在我们的 Dart、R 和 Shell 指南中进行演示的样子。另一部分风格指南注重更多细节方面,深入研究特定的语言特征并扩展内容,特别是我们的 C++、Python 和 Java 指南。还有一部分风格指南重视该语言在谷歌之外的惯例——我们的 Go 风格指南非常简短,只是在一个总结指令中添加了一些规则,以遵循外部公认的惯例。也有部分指南的规则和外部规范根本不同;我们的 C++ 风格指南中不允许使用异常,而使用异常是一种在 Google 代码之外广泛使用语言特性。 The wide variance among even our own style guides makes it difficult to pin down the precise description of what a style guide should cover. The decisions guiding the development of Google’s style guides stem from the need to keep our codebase sustainable. Other organizations’ codebases will inherently have different requirements for sustainability that necessitate a different set of tailored rules. This chapter discusses the principles and processes that steer the development of our rules and guidance, pulling examples primarily from Google’s C++, Python, and Java style guides. -即使是我们自己的风格指南也存在很大的差异,这使得我们很难精确地描述一个风格指南应该涵盖什么内容。指导谷歌风格指南开发的决定源于保持我们代码库可持续性的需要。其他组织的代码库天生对可持续性有不同的要求,这就需要一套不同的定制规则。本章讨论了指导我们规则和指南开发的原则和过程,主要从谷歌的c++、Python和Java风格指南中抽取示例。 +即使是我们自己的风格指南也存在很大的差异,这使得我们很难精确地描述一个风格指南应该涵盖什么内容。指导谷歌风格指南开发背后的决策源于维持我们代码库的可持续性需求。其他组织的代码库天生对可持续性有不同的要求,这就需要一套不同的定制规则。本章讨论了指导我们规则和指南开发的原则和过程,主要从谷歌的c++、Python和Java风格指南中抽取示例。 > [^1]: Many of our style guides have external versions, which you can find at https://google.github.io/styleguide. We cite numerous examples from these guides within this chapter. > @@ -41,9 +41,9 @@ So why do we have rules? The goal of having rules in place is to encourage “go As an organization grows, the established rules and guidelines shape the common vocabulary of coding. A common vocabulary allows engineers to concentrate on what their code needs to say rather than how they’re saying it. By shaping this vocabulary, engineers will tend to do the “good” things by default, even subconsciously. Rules thus give us broad leverage to nudge common development patterns in desired directions. -随着组织的发展,已建立的规则和指导方针形成了通用的编码词汇表。通用词汇表可以让工程师专注于他们的代码需要表达什么,而不是如何表达。通过塑造这种词汇,工程师会倾向于默认地、甚至是潜意识地去做“好”事情。因此,规则为我们提供了广泛的杠杆作用,以便将共同的开发模式推向所需的方向。 +随着组织的发展壮大,已建立的规则和指导方针形成了通用的编码词汇表。通用词汇表可以让工程师专注于他们的代码需要表达什么,而不是如何表达。通过塑造这种词汇,工程师会倾向于默认地、甚至是潜意识地去做“好”事情。因此,规则为我们提供了广泛的杠杆作用,以便将共同的开发模式推向所需的方向。 -## Creating the Rules 创建规则 +## Creating the Rules 指定规则 When defining a set of rules, the key question is not, “What rules should we have?” The question to ask is, “What goal are we trying to advance?” When we focus on the goal that the rules will be serving, identifying which rules support this goal makes it easier to distill the set of useful rules. At Google, where the style guide serves as law for coding practices, we do not ask, “What goes into the style guide?” but rather, “Why does something go into the style guide?” What does our organization gain by having a set of rules to regulate writing code?