关于软件工程:翻译软件设计的哲学21-复杂性的定义

45次阅读

共计 2967 个字符,预计需要花费 8 分钟才能阅读完成。

For the purposes of this book, I define“complexity”in a practical way. Complexity is anything related to the structure of a software system that makes it hard to understand and modify the system. Complexity can take many forms. For example, it might be hard to understand how a piece of code works; it might take a lot of effort to implement a small improvement, or it might not be clear which parts of the system must be modified to make the improvement; it might be difficult to fix one bug without introducing another. If a software system is hard to understand and modify, then it is complicated; if it is easy to understand and modify, then it is simple.

就本书而言,我以特定的形式定义了“复杂性”,就是任何对于系统结构的,会让它变得难以了解和调整的因素。复杂性能够体现成多种形式。比方,兴许是很难了解一块代码是怎么工作的;兴许是要大量工作能力做到一点点的改良;兴许是无奈清晰地看出调整零碎的哪个局部能力改良;兴许是要改一个 BUG 很难不引发其它 BUG。如果软件系统很难了解和批改,那么它就是简单的;反之则是简略的。

You can also think of complexity in terms of cost and benefit. In a complex system, it takes a lot of work to implement even small improvements. In a simple system, larger improvements can be implemented with less effort.

你也能够把复杂性看成代价和收益。简单零碎里,甚至要大量的工作能力实现一些小的改良。简略零碎里,相比之下用更小的工作量,能够取得更大的改良。

Complexity is what a developer experiences at a particular point in time when trying to achieve a particular goal. It doesn’t necessarily relate to the overall size or functionality of the system. People often use the word“complex”to describe large systems with sophisticated features, but if such a system is easy to work on, then, for the purposes of this book, it is not complex. Of course, almost all large and sophisticated software systems are in fact hard to work on, so they also meet my definition of complexity, but this need not necessarily be the case. It is also possible for a small and unsophisticated system to be quite complex.

复杂性是一个开发者想要达到特定指标时,在特定工夫点所要经验的事物。它不肯定与零碎的整体大小或者性能相干。人们罕用“简单”去形容带有简单性能的零碎,然而如果这样一个零碎容易被开发,那么就本书而言,它就不是简单的。当然,简直所有的大型且简单的软件系统,实际上是很难开发的,所以它们会体现在我对复杂性的定义上,然而也不肯定是这种状况。一个小型且性能不简单的零碎也能够是非常复杂的。

Complexity is determined by the activities that are most common. If a system has a few parts that are very complicated, but those parts almost never need to be touched, then they don’t have much impact on the overall complexity of the system. To characterize this in a crude mathematical way:

复杂性取决于最常见的流动。如果一个零碎只有一小部分形成是非常复杂的,然而这些局部简直从来不用被碰到,那么它们就不会对系统的整体复杂性有多大的影响。咱们用这个毛糙的数学公式来量化它:

The overall complexity of a system (C) is determined by the complexity of each part p (cp) weighted by the fraction of time developers spend working on that part (tp). Isolating complexity in a place where it will never be seen is almost as good as eliminating the complexity entirely.

零碎的整体复杂性(C)取决于,每个局部的复杂性(cp)加权于开发者用于开发的工夫(tp)。隔离复杂性到一个再也不会被看到的中央,简直跟毁灭整体的复杂性一样无效。

Complexity is more apparent to readers than writers. If you write a piece of code and it seems simple to you, but other people think it is complex, then it is complex. When you find yourself in situations like this, it’s worth probing the other developers to find out why the code seems complex to them; there are probably some interesting lessons to learn from the disconnect between your opinion and theirs. Your job as a developer is not just to create code that you can work with easily, but to create code that others can also work with easily.

读者会比作者更容易看到复杂性。如果你写的一段代码,对你来说很简略,然而其他人感觉简单,那么它就是简单的。如果你发现你是这种状况,去找其余开发者探寻一下为什么感觉你的代码会简单,是很有好处的。很可能会有一些乏味的值得学习的教训,在你和他们的意见分歧之中。作为开发者,你的工作不仅仅是写只有本人感觉简略应用的的代码,还要发明让其他人也能简略单干的代码。

正文完
 0