Bad Smell(代码的坏味道)

1.Duplicated Code(重复的代码)
臭味行列中首当其冲的就是Duplicated Code。如果你在一个以上的地点看到相同的程序结构,那么当可肯定:设法将它们合而为一,程序会变得更好。
最单纯的Duplicated Code就是[同一个class内的两个方法含有相同表达式(expression)]。这时候你需要做的就是采用Extract Method提炼出重复的代码,然后让这两个地点都调用被提炼出来的那一段代码。
另一种常见情况就是[两个互为兄弟(sibling)的subclasses内含有相同表达式]。要避免这种情况,只需要对两个classes都使用 Extract Method,然后再对被提炼出的代码使用Pull Up Method,将它推入superclass内。如果代码之间只是类似,并非完全相同,那么就得运用Extract Method将相似部分和差异部分割开,构成单独一个方法。然后你可能发现或许可以运用Form Template Method获得一个Template Method设计模式。如果有些方法以不同的算法做相同的事,你可以择定其中较清晰的一个,并使用Substitute Algorithm将其它方法的算法替换掉。
如果两个毫不相关的classes内出现Duplicated Code,你应该考虑对其中一个使用Extract Class,将重复代码提炼到一个独立class中,然后在另一个class内使用这个新class。但是,重复代码所在的方法也可能的确只应该属于某个 class,另一个class只能调用它,抑或这个方法可能属于第三个class,而另两个classes应该引用这第三个class。你必须决定这个方法放在哪儿最合适,并确保它被安置后就不会再在其它任何地方出现。

2.Long Method(过长方法)
拥有[短方法](short methods)的对象会活得比较好、比较长。不熟悉面向对象技术的人,常常觉得对象程序中只有无穷无尽的delegation(委托),根本没有进行任何计算。和此类程序共同生活数年之后,你才会知道,这些小小方法有多大价值。[间接层]所能带来的全部利益——解释能力、共享能力、选择能力——都是由小型方法支持的。
很久以前程序员就已认识到:程序愈长愈难理解。早期的编程语言中,[子程序调用动作]需要额外开销,这使得做你们不太乐意使用small method,现代OO语言几乎已经完全免除了进程内的[方法调用动作额外开销]。不过代码阅读者还是得多费力气,因为他必须经常转换上下文去看看子程序做了什么。某些开发环境允许用户同时看到两个方法,这可以帮助你省去部分麻烦,但是让small method容易理解的真正关键在于一个好名字。如果你能给方法起个好名字,读者就可以通过名字了解方法的作用,根本不必去看其中写了些什么。
最终的效果是:你应该更积极进取地分解方法。我们遵循这样一条原则:每当感觉需要以注释来说明点什么的时候,我们就把需要说明的东西写进一个独立的方法中,并以其用途(而非实现手法)命名。我们可以对一组或甚至短短一行代码做这件事。哪怕替换后的方法调用动作比方法自身还长,只要方法名称能够解释其用途,我们也该毫不犹豫地那么做。关键不在于方法的长度,而在于方法[做什么]和[如何做]之间的语义距离。
百分之九十九的场合里,要把方法变小,只需使用Extract Method。找到方法中适合集在一起的部分,将它们提炼出来形成一个新方法。
如果方法内有大量的参数和临时变量,它们会对你的方法提炼形成阻碍。如果你尝试运用Extract Method,最终就会把许多这些参数和临时变量当作参数,传递给被提炼出来的新方法,导致可读性几乎没有任何提升。啊是的,你可以经常运用 Replace Temp with Query则可以将过长的参数列变得更简洁一些。
如果你已经这么做,仍然有太多临时变量和参数,那就应该拿出我们的杀手锏:Replace Method with Method Object。
如何确定该提炼哪一段代码呢?一个很好的技巧是:寻找注释。它们通常是指出[代码用途和实现手法间的语义距离]的信号。如果代码前言有一行注释,就是在提醒你:可以将这段代码替换成一个方法,而且可以在注释的基础上给这个方法命名。就算只有一行代码,如果它需要以注释来说明,那也值得将它提炼到独立的方法去。
条件式和循环常常也是提炼的信号。你可以使用Decompose Conditional处理条件式。至于循环,你应该将循环和其内的代码提炼到一例独立方法中。

3.Large Class(过大类)
如果想利用单一class做太多事情,其内往往就会出现太多instance变量。一旦如此,Duplicated Code也就接踵而至了。
你可以运用Extract Class将数个变量一直提炼到新class内。提炼时应该选择class内彼此相关的变量,将它们放在一直。例如”depositAmount” 和”depositCurrency”可能应该隶属同一个class。通常如果class内的数个变量有着相同的前缀或字尾,这就意味有机会把它们提炼到某个组件内。如果这个组件适合作为一个subclass,你会发现Extract Subclass往往比较简单。
有时候class并非在所有时刻都使用所有instance变量。果真如此,你或许可以多次使用Extract Class或Extract Subclass。
和[太多instance变量]一样,class内如果有太多代码,也是[]代码重复、混乱、死亡]的绝佳滋生地点。最简单的解决方案是把赘余的东西消弭于class内部。如果有五个[百行方法],它们之中很多代码都相同,那么或许你可以把它们变成五个[十行方法]和十个提炼出来的[双行方法]。
和[拥有太多instance变量]一样,一个class如果拥有太多代码,往往也适合使用Extract Class和Extract Subclass。这里有个有用技巧:先确定客户端如何使用它们,然后运用Extract Interface为每一种使用一个接口。这或许可以帮助你看清楚如何分解这个class。
如果你的Large Class是个GUI class,你可能需要把数据和行为移到一个独立的领域对象去。你可能需要两边各保留一些重复数据,并令这些数据同步。Duplicate Observed Data告诉你该怎么做。这种情况下,特别是如果你使用旧式AWT组件,你可以采用这种方式去掉GUI class并代以Swing组件。

4.Long Parameter List(过长参数列)

刚开始学习编程的时候,老师教我们:把方法所需的所有东西都以参数传递进去。这可以理解,因为除此之外就只能选择全局数据,而全局数据是邪恶的东西。对象技术改变了这一情况,因为如果你手上没有你所需要的东西,总可以叫另一个对象给你。因此,有了对象,你就不必把方法需要的所有东西都以参数传递给它了,你只需给它足够的东西、让方法能从中获得自己需要的所有东西就行了。方法需要的东西多半可以在方法的宿主类(host class)中找到。面向对象程序中的方法,其参数列通常比在传统程序中短得多。
这是好现象,因为太长的参数列难以理解,太多参数会造成前后不一致、不易使用,而且一旦你需要更多数据,就不得不修改它。如果将对象传递给方法,大多数修改都将没有必要,因为你很可能只需(在方法内)增加一两条请求,就能得到更多数据。
如果[向既有对象发出一条请求]就可以取得原本位于参数列上的一份数据,那么你应该激活重构准则Replace Parameter with Method。上述的既有对象可能是方法所属class内的一个字段,也可能是另一个参数。你还可以运用Preserve Whole Object将来自同一对象的一堆数据收集起来,并以该对象替换它们。如果某些数据缺乏合理的对象归属,可使用Introduce Parameter Object为它们制造出一个[参数对象]。
此间存在一个重要的例外。有时候你明显不希望造成[被调用之对象]与[较大对象]间的某种依存关系。这时候将数据从对象中拆解出来单独作为参数,也很合情合理。但是请注意其所引发的代价。如果参数列太长或变化太频繁,你就需要重新考虑自己的依存结构了。

5.Divergent Change(发散式变化)

我们希望软件能够更容易被修改——毕竟软件再怎么说本来就该是[软]的。一旦需要修改,我们希望能够跌到系统的某一点,只在该处做修改。如果不能做到这点,你就嗅出两种紧密相关的刺鼻味道中的一种了。
如果某个class经常因为不同的原因在不同的方向上发生变化,Divergent Change就出现了。当你看着一个class说:“ 呃,如果新加入一个数据库,我必须修改这三个方法;如果新出现一种金融工具,我必须修改这四个方法”,那么此时也许将这个对象分成两个会更好,这么一来每个对象就可以只因一种变化而需要修改。当然,往往只有在加入新数据库或新金融工具后,你才能发现这一点。针对某一外界变化的所有相应修改,都只应该发生在单一class中,而这个新class内的所有内容都应该反应该外界变化。为此,你应该找出因着某特定原因而造成的所有变化,然后运用Extract Class将它们提炼到另一个class中。

6.Shotgun Surgery(霰弹式修改)

Shotgun Surgery类似Divergent Change,但恰恰相反。如果每遇到某种变化,你都必须在许多不同的class内做出许多小修改以响应之,你所面临的坏味道就是Shotgun Surgery。如果需要修改的代码散布四处,你不但很难找到它们,也很容易忘记某个重要的修改。
这种情况下你应该使用Move Method和Move Field把所有需要修改的代码放进同一个class。如果眼下没有合适的class可以安置这些代码,就创造一个。通常你可以运用Inline Class把一系列相关行为放进同一个class。这可能会造成少量Divergent Change,但你可以轻易处理它。
Divergent Change是指[一个class受多种变化的影响],Shotgun Surgery则是指[一种变化引发多个classes相应修改]。这两种情况下你都会希望整理代码,取得[外界变化]与[待改类]呈现一对一关系的理想境地。

7.Feature Envy(依恋情结)

对象技术的全部要点在于:这是一种[将数据和加诸其上的操作行为包装在一起]的技术。有一种经典气味是:方法对某个class的兴趣高过对自己所处之 host class的兴趣。这种孺慕之情最通常的焦点便是数据。无数次经验里,我们看到某个方法为了计算某值,从另一个对象那儿调用几乎半打的取值方法。疗法显而易见:把这个方法移到另一个地点。你应该使用Move Method把它移到它该去的地方。有时候方法中只有一部分受这种依恋之苦,这时候你应该使用Extract Method把这一部分提炼到独立方法中,再使用Move Method带它去它的梦中家园。
当然,并非所有情况都这么简单。一个方法往往会用上数个classes特性,那么它究竟该被置于何处呢?我们的原则是:判断哪个class拥有最多[被此方法使用]的数据,然后就把这个方法和那些数据摆在一起。如果先以Extract Method将这个方法分解为整个较小方法并分别置放于不同地点,上述步骤也就比较容易完成了。
有数个复杂精巧的模式破坏了这个规则。说起这个话题,[四巨头]的Streategy和Visitor立刻跳入我的脑海,Kent Beck的Self Delegation也丰此列。使用这些模式是为了对抗坏味道Divergent Change。最根本的原则是:将总是一起变化的东西放在一块儿。[数据]和[引用这些数据]的行为总是一起变化的,但也有例外。如果例外出现,我们就搬移那些行为,保持[变化只在一起发生]。Strategy和Visitor使你得以轻松修改方法行为,因为它们将少量需要被覆写的行为隔离开来——当然也付出了[多一层间接性]的代价。

8.Data Clumps(数据泥团)

数据项就像小孩子:喜欢成群结队地待在一块儿。你常常可以在很多地方看到相同的三或四笔数据项:两个classes内的相同字段、许多方法签名式中的相同参数。这些[总是绑在一起出现的数据]真应该放进属于它们自己的对象中。首先请找出这些数据的字段形式出现点,运用Extract Class将它们提炼到一个独立对象中。然后将注意力转移到方法签名式上头,运用Introduce Parameter Object或Preserve Whole Object为它减肥。这么做的直接好处是可以将很多参数列缩短,简化方法调用动作。是的,不必因为Data Clumps只用上新对象的一部分字段而在意,只要你以新对象取代两个(或更多)字段,你就值回票价了。
一个好的评断办法是:删掉众多数据中的一笔。其它数据有没有因而失去意义?如果它们不再有问询,这就是个明确信号:你应该为它们产生一个新对象。
缩短字段个数和参数个数,当然可以支队一些坏味道,但更重要的是:一旦拥有新对象,你就有机会让程序散发出一种芳香。得到新对象后,你就可以着手寻找 Feature Envy,这可以帮你指出[可移到新class]中的种种程序行为。不必太久,所有classes都将在它们的小小社会中充分发挥自己的生产力。

9.Primitive Obsession(基本型别偏执)

大多数编程环境都有两种数据:结构型别允许你将数据组织成有意义的形式;基本型别则是构成结构型别的积木块。结构总是会带来一定的额外开销。它们有点像数据库中的表格,或是那些得不偿失的东西。
对象的一个极具价值的东西早到:它们模糊了横亘于基本数据和体积较大的classes之间的界限。你可以轻松编写出一些与语言内置型别无异的小型 classes。例如Java就以基本型别表示数值,而心class表示字符串和日期——这两个型别在其它许多编程环境中都以基本型别表现。
对象技术的新手通常在小任务上运用小对象——像是结合数值和币别的money class、含一个起始值和一个结束值的range class、电话号码或邮政编码等等的特殊strings。你可以运用Replace Data Value with Object将原本单独存在的数据值替换为对象,从而走出传统的洞窟,进入炙手可热的对象世界。如果欲替换之数据值是type code,而它并不影响行为,你可以运用Replace Type Code with Class将它换掉。如果你有相依于此type code的条件式,可运用Replace Type Code with Subclass或Replace Type Code with State/Strategy加以处理。
如果你有一组应该总是被放在一起的字段,可运用Extract Class。如果你在参数列中看到基本型数据,不妨试试Introduce Parameter Object。如果你发现自己正从array中挑选数据,可运用Replace Array with Object。

10.Switch Statements(switch惊悚现身)

面向对象程序的一个最明显特征就是:少用switch(或case)语句。从本质上说,switch语句的问题在于重复。你常会发现同样的switch语句散布于不同的地点。如果要为它添加一个新的case子句,你必须找到所有switch语句并修改它们。面向的多态概念可为此带来优雅的解决办法。
大多数时候,一看到switch语句你就应该考虑以多态来替换它。问题是多态该出现在哪儿?switch语句常常根据type code进行选择,你要的是[与该type code相关的方法或class]。所以你应该使用Extract Method将switch语句提炼到一个独立方法中,再以Move Method将它搬移到需要多态性的那个class里头。此时你必须决定是否使用Replace Type Code with Subclasses或Replace Type Code with State/Strategy。一旦这样完成继承结构之后,你就可以运用Replace Conditional with Polymorphism了。
如果你只是在单一方法中髭选择事例,而你并不想改动它们,那么[多态]就有点杀鸡用牛刀了。这种情况下Replace Parameter with Explicit Methods是个不错的选择。如果你的选择条件之一是null,可以试试Introduce Null Object。

11.Parallel Inheritance Hierarchies(平等继承体系)

Parallel Inheritance Hierarchies其实是Shotgun Surgery的特殊情况。在这种情况下,每当你为某个class增加一个subclass,必须也为另一个class相应增加一个subclass。如果你发现某个继承体系的class名称前缀和另一个继承体系的class名称前缀完全相同,便是闻到了这种坏味道。
消除这种重复性的一般策略是:让一个继承体系的实体指涉另一个继承体系的实体。如果再接再厉运用Move Method和Move Field,就可以将指涉端的继承体系消弭于无形。

12.Lazy Class(冗赘类)

你所创建的每一个class,都得有人去理解它、维护它,这些工作都是要花钱的。如果一个class的所得不值其身份,它就应该消失。项目中经常会出现这样的情况:某个class原本对得起自己的身份,但重檐使它身形缩水,不再做那么多工作;或开发者事前规划了某些变化,并添加一个class来就会这些变化,但变化实际上没有发生。不论上述哪一种原因,请让这个class庄严赴义吧。如果某些subclass没有做满足够工作,试试Collapse Hierarchy[合并继承]。对于几乎没用的组件,你应该以Inline Class对付它们。

13.Speculative Generality(夸夸其谈未来性)

这个令我们十分敏感的坏味道,命名者是Brian Foote。当有人说“噢,我想我们总有一天需要做这事”并因而企图以各式各样的挂勾和特殊情况来处理一些非必要的事情,这种坏味道就出现了。那么做的结果往往造成系统更难理解和维护。如果所有装置都会被用到,那就值得那么做;如果用不到,就不值得。用不上的装置只会挡你的路,所以,把它搬弄吧。
如果你的某个abstract class其实没有太大作用,请运用Collapse Hierarchy。非必要之delegation可运用Inline Class除掉。如果方法的某些参数示被用上,可对它实施Rename Method让它现实一些。
如果方法或class的惟一用户是test cases,这就飘出了坏味道Speculative Generality。如果你发现这样的方法或class,请把它们连同其test cases都删掉。但如果它们的用途是帮助test cases检测正当功能,当然必须刀下留人。

14.Temporary Field(令人迷惑的暂时字段)

有时你会看到这样的对象:其内某个instance 变量仅为某种特定情势而设。这样的代码让人不易理解,因为你通常认为对象在所有时候都需要它的所有变量。在变量未被使用的情况下猜测当初其设置目的,会让你发疯。
请使用Extract Class给这个可怜的孤独创造一个家,然后把所有和这个变量相关的代码都放进这个新家。也许你还可以使用Introduce Null Object在[变量不合法]的情况下创建一个Null对象,从而避免写出[条件式代码]。
如果class中有一个复杂算法,需要好几个变量,往往就可能导致坏味道Temporary Field的出现。由于实现者不希望传递一长串参数,所以他把这些参数都放进字段中。但是这些字段只在使用该算法时才有效,其它情况下只会让人迷惑。这时候你可以利用Extract Class把这些变量和其相关方法提炼到一个独立class中。提炼后的新对象将是一个method object。

15.Message Chains(过度耦合的消息链)

如果你看到用户向一个对象索求另一个对象,然后再向后者索求另一个对象,然后再索求另一个对象……这就是Message Chain。实际代码中你看到的可能是一长串getThis()或一长串临时变量。采取这种方式,意味客户将与查找过程中的航行结构紧密耦合。一旦对象间的关系发生任何变化,客户端就不得不做出相应修改。
这时候你应该使用Hide Delegate。你可以在Message Chain的不同位置进行这种重构手法。理论上你可以重构Message Chain上的任何一个对象,但这么做往往会把所有中介对象都变成Middle Man。通常更好的选择是:先观察Message Chain最终得到的对象是用来干什么的,看看能否以Extract Method把使用该对象的代码提炼到一个独立方法中,再运用Move Method把这个方法推入Message Chain。如果这条链上的某个对象有多位客户打算航行此航线的剩余部分,就加一个方法来做这件事。
有些人把任何方法链都视为坏东西,我们不这样想。呵呵,我们的总代表镇定是出了名的,起码在这件事情上是这样。

16.Middle Man(中间转手人)

对象的基本特征之一就是封装——对外部世界隐藏其内部细节。封装往往伴随delegation。比如说你问主管是否有时间参加一个会议,他就把这个消息委托给他的记事簿,然后才能回答你。很好,你没必要知道这位主管到底使用传统记事簿或电子记事簿抑或秘书来记录自己的约会。
但是人们可能过度运用delegation。你也许会看到某个class接口有一半的方法都委托给其它class,这样就是过度运用。这里你应该使用 Remove Middle Man,直接和负责对象打交道。如果这样[不干实事]的方法只有少数几个,可以运用Inline Method把它们”inlining”,放进调用端。如果这些Middle Man还有其它行为内销可以运用Replace Delegation with Inheritance把它变成负责对象的subclass,这样你既可以扩展原对象的行为,又不必负担那么多的委托动作。

17.Inappropriate Intimacy(狎昵关系)

有时候你会看到两个classes过于亲密,花费太多时间去探究彼此的private成分。如果这发生在两个[人]之间,我们不必做卫道之士;但对于 classes,我们希望它们严守清规。
就像古代恋人一样,过份狎昵的classes必须拆散。你可以采用Move Method和Move Field帮它们划清界线,从而减少狎昵行径。你也可以看看是否运用Change Bidirectional Association to Unidirectional[将双向关联改为单向]让其中一个class对另一个斩断情丝。如果两个classes实在情投意合,可以运用Extract Class把两者共同点提炼到一个安全地点,让它们坦荡地使用这个新class。或者也可以尝试运用Hide Delegate让另一个class来为它们传递相思情。
继承往往造成过度亲密,因为subclass对superclass的了解总是超过superclass的主观愿望。如果你觉得该让这个孩子独自生活了,请运用Replace Inheritance with Delegation让它离开继承体系。

18.Alternative Classes with Different Interfaces(异曲同工的类)

如果两个方法做同一件事,却有着不同的签名式,请运用Rename Method根据它们的用途重新命名。但这往往不够,请反复运用Move Method将某些行为移入classes,直到两者的协议一致为止。如果你必须重复而赘余地移入代码才能完成这些,或许可运用Extract Superclass为自己赎点罪。

19.Incomplete Library Class(不完美的程序库类)

复用常被视为对象的终极目的。我们认为这实在是过度估计了。但是无可否认,许多编程技术都建立在library classes的基础上,没人敢说是不是我们都把排序算法忘得一干二净了。
Library classes构筑者没有未卜先知的能力,我们不能因此责怪他们。毕竟我们自己也几乎总是在系统快要构筑完成的时候才能弄清楚它的设计,所以 library构筑者的任务真的很艰巨。麻烦的是library的形式往往不够好,往往不可能让我们修改其中的classes使它完成我们希望完成的工作。这是否意味那些经过实践检验的战术如Move Method等等,如今都派不上用场了?
幸好我们有两个专门就会这种情况的工具。如果你只想修改library classes内的一两个方法,可以运用Introduce Foreign Method;如果想要添加一大堆额外行为,就得运用Introduce Local Extension。

20.Data Class(纯稚的数据类)

所谓Data Class是指:它们拥有一些字段,以及用于访问这些字段的方法,除此之外一无长物。这样的classes只是一种[不会说话的数据容器],它们几乎一定被其它classes过份细琐地操控着。这些classes早期可能拥有public字段,果真如此你应该在别人注意到它们之前,立刻运用 Encapsulate Field将它们封装起来。如果这些classes内含容器类的字段,你应该检查它们是不是得到了恰当的封装;如果没有,就运用Encapsulate Collection把它们封装起来。对于那些不该被其它classes修改的字段,请运用Remove Setting Method。
然后,找出这些[取值/设值]方法被其它classes运用的地点。尝试以Move Method把那些调用行为搬移到Data Class来。如果无法搬移整个方法,就运用Extract Method产生一个可被搬移的方法。不久之后你就可以运用Hide Method把这些[取值/设值]方法隐藏起来了。
Data Class就像小孩子。作为一个起点很好,但若要让它们像[成年]的对象那样参与整个系统的工作,它们就必须承担一定责任。

21.Refused Bequest(被拒绝的遗赠)

Subclasses应该继承superclass的方法和数据。但如果它们不想或不需要继承,又该怎么办呢?它们得到所有礼物,却只从中挑选几样来玩!
按传统说法,这就意味继承体系设计错误。你需要为这个subclass新建一个兄弟,再运用Push Down Method和Push Down Field把所有用不到的方法下推给那兄弟。这样一来superclass就只持有所有subclasses共享的东西。常常你会听到这样的建议:所有 superclasses都应该是抽象的。
既然使用[传统说法]这个略带贬义的词,你就可以猜到,我们不建议你这么做,起码不建议你每次都这么做。我们经常利用subclassing手法来复用一些行为,并发现这可以很好地应用于日常工作。这也是一种坏味道,我们不否认,但气味通常并不强烈。所以我们说:如果Refused Bequest引起困惑和问题,请遵循传统忠告。但不必认为你每次都得那么做。十有八九这种坏味道很淡,不值得理睬。
如果subclass复用了superclass的行为(实现),却又不愿意支持superclass的接口,Refused Bequest的坏味道就会变得浓烈。拒绝继承superclass的实现,这一点我们不介意;但如果拒绝继承superclass的接口,我们不以为然。不过即使你不愿意继承接口,也不要胡乱修改继承系,你应该运用Replace Inheritance with Delegation来达到目的。

22.Comments(过多的注释)

别担心,我们并不是说你不该写注释。从嗅觉上说,Comments不是一种坏味道;事实上它们还是一种香味呢。我们之所以要在这里提到Comments,因为人们常把它当作除臭剂来使用。常常会有这样的情况:你看到一段代码有着长长的注释,然后发现,这些注释之所以存在乃是因为代码很糟糕。这种情况的发生次数之多,实在令人吃惊。
Comments可以带我们找到本章先前提到的各种坏味道。找到坏味道后,我们首先应该以各种重构手法把坏味道去除。完成之后我们常常会发现:注释已经变得多余了,因为代码已经清楚说明了一切。
如果你需要注释来解释一块代码做了什么,试试Extract Method;如果你需要注释说明某些系统的需求规格,试试Introduce Assertion。
如果你不知道该做什么,这才是注释的良好运用时机。除了用来记述将来的打算之外,注释还可以用来标记你并无十足把握的区域。你可以在注释里写下自己[为什么做某某事]。这类信息可以帮助将来的修改者,尤其是那些健忘的家伙。

乔布斯斯坦福大学演讲全文

这是苹果公司和Pixar动画工作室的CEO Steve Jobs于2005年6月12号在斯坦福大学的毕业典礼上面的演讲稿。

点击下载音频 


I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I’ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That’s it. No big deal. Just three stories.

我今天很荣幸能和你们一起参加毕业典礼,斯坦福大学是世界上最好的大学之一。我从来没有从大学中毕业。说实话,今天也许是在我的生命中离大学毕业最近的一天了。今天我想向你们讲述我生活中的三个故事。不是什么大不了的事情,只是三个故事而已。

The first story is about connecting the dots.

第一个故事是关于“因”和“果”。

I dropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?

我在Reed大学读了六个月之后就退学了,但是在十八个月以后——我真正的作出退学决定之前,我还经常去学校。我为什么要退学呢?

It started before I was born. My biological mother was a young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: “We have an unexpected baby boy; do you want him?” They said: “Of course.” My biological mother later found out that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would someday go to college.

故事从我出生的时候讲起。我的亲生母亲是一个年轻的,没有结婚的大学毕业生。她决定让别人收养我, 她十分想让我被大学毕业生收养。所以在我出生的时候,她已经做好了一切的准备工作,能使得我被一个律师和他的妻子所收养。但是她没有料到,当我出生之后,律师夫妇突然决定他们想要一个女孩。 所以我的生养父母(他们还在我亲生父母的观察名单上)突然在半夜接到了一个电话:“我们现在这儿有一个不小心生出来的男婴,你们想要他吗?”他们回答道:“当然!”但是我亲生母亲随后发现,我的养母从来没有上过大学,我的父亲甚至从没有读过高中。她拒绝签这个收养合同。但是在几个月以后,我的父母答应她一定要让我上大学,那个时候她才同意。

And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents’ savings were being spent on my college tuition. After six months, I couldn’t see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn’t interest me, and begin dropping in on the ones that looked interesting.

在十七岁那年,我真的上了大学。但是我很天真的选择了一个几乎和你们斯坦福大学一样贵的学校, 我父母还处于蓝领阶层,他们几乎把所有积蓄都花在了我的学费上面。在六个月后, 我已经看不到其中的价值所在。我不知道我想要在生命中做什么,我也不知道大学能帮助我找到怎样的答案。 但是在这里,我几乎花光了我父母这一辈子的所有积蓄。所以我决定要退学,我觉得这是个正确的决定。不能否认,我当时确实非常的害怕, 但是现在回头看看,那的确是我这一生中最明智的一个决定。在我做出退学决定的那一刻, 我终于可以不必去读那些令我提不起丝毫兴趣的课程了。然后我还可以去修那些看起来有点意思的课程。

It wasn’t all romantic. I didn’t have a dorm room, so I slept on the floor in friends’ rooms, I returned coke bottles for the 5¢ deposits to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:

但是这并不是那么罗曼蒂克。我失去了我的宿舍,所以我只能在朋友房间的地板上面睡觉,我去捡5美分的可乐瓶子,仅仅为了填饱肚子, 在星期天的晚上,我需要走七英里的路程,穿过这个城市到Hare Krishna寺庙(注:位于纽约Brooklyn下城),只是为了能吃上饭——这个星期唯一一顿好一点的饭。但是我喜欢这样。我跟着我的直觉和好奇心走, 遇到的很多东西,此后被证明是无价之宝。让我给你们举一个例子吧:

Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn’t have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can’t capture, and I found it fascinating.

Reed大学在那时提供也许是全美最好的美术字课程。在这个大学里面的每个海报, 每个抽屉的标签上面全都是漂亮的美术字。因为我退学了, 没有受到正规的训练, 所以我决定去参加这个课程,去学学怎样写出漂亮的美术字。我学到了san serif 和serif字体, 我学会了怎么样在不同的字母组合之中改变空格的长度, 还有怎么样才能作出最棒的印刷式样。那是一种科学永远不能捕捉到的、美丽的、真实的艺术精妙, 我发现那实在是太美妙了。

None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, its likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computers might not have the wonderful typography that they do. Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.

当时看起来这些东西在我的生命中,好像都没有什么实际应用的可能。但是十年之后,当我们在设计第一台Macintosh电脑的时候,就不是那样了。我把当时我学的那些家伙全都设计进了Mac。那是第一台使用了漂亮的印刷字体的电脑。如果我当时没有退学, 就不会有机会去参加这个我感兴趣的美术字课程, Mac就不会有这么多丰富的字体,以及赏心悦目的字体间距。因为微软就是苹果的山寨版,可以说世上所有PC都不会有现在这么美妙的字型了。当然我当时不可能预知这事事之间的“因”“果”,但是当我十年后回顾这一切的时候,真的豁然开朗了。

Again, you can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something – your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.

再次说明的是,没人可以未卜先知,事事的因果往往只在回首时显现,你得相信,种什么因,得什么果。人总要有些信仰才行,直觉也好,命运也罢,因果轮回,不管什么。去相信因果的联系,会给你信心去跟从自己的意愿,哪怕离经叛道,也绝不止步。只有这样,才能有所成。

My second story is about love and loss.

我的第二个故事是关于爱和得失的。

I was lucky – I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a $2 billion company with over 4000 employees. We had just released our finest creation – the Macintosh – a year earlier, and I had just turned 30. And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating.

我非常幸运, 因为我在很早的时候就找到了我钟爱的东西。Woz和我在二十岁的时候就在父母的车库里面开创了苹果公司。我们工作得很努力, 十年之后, 这个公司从那两个车库中的穷光蛋发展到了超过四千名的雇员、价值超过二十亿的大公司。在公司成立的第九年,我们刚刚发布了最好的产品,那就是Macintosh。我也快要到三十岁了。在那一年, 我被炒了鱿鱼。你怎么可能被你自己创立的公司炒了鱿鱼呢? 嗯,在苹果快速成长的时候,我们雇用了一个很有天分的家伙和我一起管理这个公司, 在最初的几年,公司运转的很好。但是后来我们对未来的看法发生了分歧, 最终我们吵了起来。当争吵不可开交的时候, 董事会站在了他的那一边。所以在三十岁的时候, 我被当众扫地出门。在而立之年,我一生的追求突然不见了, 这真是沉重的打击。

I really didn’t know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down – that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me – I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.

在最初的几个月里,我不知所措。我把从前的创业激情给丢了, 我觉得自己让与我一同创业的人都很沮丧。我和David Pack和Bob Boyce见面,并试图向他们道歉。我把事情弄得糟糕透顶了。但是我渐渐发现了曙光, 我仍然喜爱我从事的这些东西。苹果公司发生的这些事情丝毫的没有改变这些, 一点也没有。我被驱逐了,但是我仍然钟爱它。所以我决定从头再来。

I didn’t see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.

我当时没有觉察, 但是事后证明, 从苹果公司被炒是我这辈子发生的最棒的事情。因为,作为一个成功者的极乐感觉被作为一个创业者的轻松感觉所重新代替: 对任何事情都不那么特别看重。这让我觉得如此自由, 进入了我生命中最有创造力的一个阶段。

During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the worlds first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I retuned to Apple, and the technology we developed at NeXT is at the heart of Apple’s current renaissance. And Laurene and I have a wonderful family together.

在接下来的五年里, 我创立了一个名叫NeXT的公司, 还有一个叫Pixar的公司, 然后和一个后来成为我妻子的优雅女人相识。Pixar 制作了世界上第一个用电脑制作的动画电影——“”玩具总动员”,Pixar现在也是世界上最成功的电脑制作工作室。峰回路转,Apple收购了NeXT, 然后我又回到了Apple公司。我们在NeXT发展的技术在Apple的复兴之中发挥了关键的作用。我还和Laurence 一起建立了一个幸福的家庭。

I’m pretty sure none of this would have happened if I hadn’t been fired from Apple. It was awful tasting medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don’t lose faith. I’m convinced that the only thing that kept me going was that I loved what I did. You’ve got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven’t found it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don’t settle.

我可以非常肯定,如果我不被Apple开除的话, 这其中一件事情也不会发生的。良药苦口利于病,但是我想病人需要这个药。有些时候, 生活会拿起一块砖头向你的脑袋上猛拍一下。不要失去信心。我坚信,唯一使我一直走下去的,就是我对自己事业的热爱。你必须去寻找自己所爱。对于工作是如此, 对于你的爱人也是如此。你的工作将是此生命的主题之一。要获得真正的满足感,就要对它的价值深信不疑,也只有热爱,才可能开创伟大的事业。如果你现在还没有找到, 那么继续找、不要停下来、全心全意的去找, 当你找到的时候你就会知道的。就像你找到注定的伴侣, 岁月的流逝只会令你们的感情愈发深刻。所以千万不要气馁,不要放弃。

My third story is about death.

我的第三个故事是关于死亡的。

When I was 17, I read a quote that went something like: “If you live each day as if it was your last, someday you’ll most certainly be right.” It made an impression on me, and since then, for the past 33 years, I have looked in the mirror every morning and asked myself: “If today were the last day of my life, would I want to do what I am about to do today?” And whenever the answer has been “No” for too many days in a row, I know I need to change something.

当我十七岁的时候, 我读到了一句话:“如果你把每一天都当作生命中最后一天去生活的话,那么有一天你会发现你是正确的。”这句话给我留下了深刻的印象。从那时开始,过了33年,我在每天早晨都会对着镜子问自己:“如果今天是我生命中的最后一天, 你会不会完成你今天想做的事情呢?”当答案连续很多次被给予“不是”的时候, 我知道自己需要改变某些事情了。

Remembering that I’ll be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything – all external expectations, all pride, all fear of embarrassment or failure – these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.

“记住你即将死去”是我一生中遇到的最重要箴言。它帮我指明了生命中重要的选择。因为几乎所有的事情, 包括所有的荣誉、所有的骄傲、所有对难堪和失败的恐惧,这些在死亡面前都那么微不足道。只需考虑那些真正重要的东西。你有时候会思考你将会失去某些东西,“记住你即将死去”可以有效杜绝我们的侥幸心理。既然将一无所有, 还有什么理由违背自己的意愿。

About a year ago I was diagnosed with cancer. I had a scan at 7:30 in the morning, and it clearly showed a tumor on my pancreas. I didn’t even know what a pancreas was. The doctors told me this was almost certainly a type of cancer that is incurable, and that I should expect to live no longer than three to six months. My doctor advised me to go home and get my affairs in order, which is doctor’s code for prepare to die. It means to try to tell your kids everything you thought you’d have the next 10 years to tell them in just a few months. It means to make sure everything is buttoned up so that it will be as easy as possible for your family. It means to say your goodbyes.

大概一年以前, 我被诊断出癌症。我在早晨七点半做了一个检查, 检查清楚的显示在我的胰腺有一个肿瘤。我当时都不知道胰腺是什么东西。医生告诉我那很可能是一种无法治愈的癌症, 我还有三到六个月的时间活在这个世界上。我的医生叫我回家, 然后整理好我的一切, 那就是医生准备死亡的程序。那意味着你将要把未来十年对你小孩说的话在几个月里面说完.;那意味着把每件事情都搞定, 让你的家人会尽可能轻松的生活;那意味着你要说“再见了”。

I lived with that diagnosis all day. Later that evening I had a biopsy, where they stuck an endoscope down my throat, through my stomach and into my intestines, put a needle into my pancreas and got a few cells from the tumor. I was sedated, but my wife, who was there, told me that when they viewed the cells under a microscope the doctors started crying because it turned out to be a very rare form of pancreatic cancer that is curable with surgery. I had the surgery and I’m fine now.

那张诊断书挥之不去。后来有一天早上我作了一个活切片检查,医生将一个内窥镜从我的喉咙伸进去,通过我的胃, 然后进入我的肠子, 用一根针在我的胰腺上的肿瘤上取了几个细胞。我当时很镇静,因为我被注射了镇定剂。但是我的妻子在那里, 后来告诉我,当医生在显微镜地下观察这些细胞的时候他们不住叫喊, 因为这些细胞最后竟然是一种非常罕见的可以用手术治愈的胰腺癌症。我做了这个手术, 现在我痊愈了。

This was the closest I’ve been to facing death, and I hope its the closest I get for a few more decades. Having lived through it, I can now say this to you with a bit more certainty than when death was a useful but purely intellectual concept:

那是我最接近死亡的时候, 我还希望这也是以后的几十年最接近的一次。从死亡线上又活了过来, 死亡对我来说,只是一个有用但是纯粹是知识上的概念的时候,我可以更肯定一点地对你们说:

No one wants to die. Even people who want to go to heaven don’t want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of Life. It is Life’s change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true.

没有人愿意死, 即使人们想上天堂, 人们也不会为了去那里而死。但是死亡是我们每个人共同的终点。从来没有人能够逃脱它。也应该如此。 因为死亡就是生命中最好的一个发明。它是生命更迭的媒介,推动世界的“新陈代谢”。现在的你们代表“新”的, 但是从现在开始不久以后, 你们将会逐渐的变成“陈”的然后被“代谢”。我很抱歉说得这么夸张, 但是这都是事实。

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma – which is living with the results of other people’s thinking. Don’t let the noise of other’s opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.

你们的时间很有限, 所以不要将他们浪费在重复其他人的生活上。不要被教条束缚,那就是走别人的老路。不要被其他人喧嚣的观点掩盖你真正的内心的声音。还有最重要的是, 你要有勇气去听从你直觉和心灵的指示——它们从来都知道你想要成为什么样的人,所有其他的一切都是次要的。

When I was young, there was an amazing publication called The Whole Earth Catalog, which was one of the bibles of my generation. It was created by a fellow named Stewart Brand not far from here in Menlo Park, and he brought it to life with his poetic touch. This was in the late 1960’s, before personal computers and desktop publishing, so it was all made with typewriters, scissors, and polaroid cameras. It was sort of like Google in paperback form, 35 years before Google came along: it was idealistic, and overflowing with neat tools and great notions.

当我年轻的时候, 有一本很棒的叫做《全球目录》的杂志,它是我们那一代人的圣经之一。它是一个叫Stewart Brand的家伙在离这里不远的Menlo Park书写的, 他把自己的文艺气息融入其中。那是六十年代后期, 在个人电脑出现之前, 所以这本书全部是用打字机,、剪刀还有偏光镜制造的。有点像用软皮包装的google, 在google出现三十五年之前:充满理想主义的, 该书简洁实用,见解独到。

Stewart and his team put out several issues of The Whole Earth Catalog, and then when it had run its course, they put out a final issue. It was the mid-1970s, and I was your age. On the back cover of their final issue was a photograph of an early morning country road, the kind you might find yourself hitchhiking on if you were so adventurous. Beneath it were the words: “Stay Hungry. Stay Foolish.” It was their farewell message as they signed off. Stay Hungry. Stay Foolish. And I have always wished that for myself. And now, as you graduate to begin anew, I wish that for you.

Stewart和他的伙伴出版了几期的“整个地球的目录”,当它完成了自己使命的时候, 他们做出了最后一期的目录。那是在七十年代的中期, 你们的时代。在最后一期的封底上是清晨乡村公路的照片,就是那种假如你搭车旅行玩冒险,也会遇到的那种村路,在照片之下有这样一段话:“求知若渴,虚心若愚。”这是他们停止了发刊的告别语。“求知若渴,虚心若愚。”我总是希望自己能够那样,现在, 在你们即将毕业,开始新的旅程的时候, 我也希望你们能这样:

Stay Hungry. Stay Foolish.

求知若渴,虚心若愚。

Thank you all very much.

非常感谢你们。

The Next Apple-FBI Question: Who Can Know How The iPhone Was Hacked?

RENEE MONTAGNE, HOST:

Experts on encryption from Apple, the FBI, law enforcement – they’re all on Capitol Hill today to testify at another hearing. It’s now well-known that a third party helped the FBI unlock the iPhone used by one of the San Bernardino shooters. At least one of the people involved was a gray hat hacker according to The Washington Post – a professional hacker in it for the money.


ROBERT KNAKE: Now what we’re seeing are these third-party groups whose full-time job is to discover vulnerabilities[,vʌlnərə’bɪləti 漏洞] that they can exploit[ɪk’splɔɪt 利用] and sell – sometimes back to governments, sometimes back to the companies that make the software and then oftentimes on the black market or on the gray market to criminals or other intelligence agencies[情报机构].


MONTAGNE: Robert Knake led cyber security policy for the White House National Security Council[‘kaʊnsl 委员会] until last year, and he joined us to talk more about it.


KNAKE: That’s one of the challenges that we’re seeing today is if this company, this third party, discovered this vulnerability, they probably didn’t want to give it to the FBI one time. They probably wanted to keep reselling it to the FBI over and over again and to other law enforcement agencies. And so we may be in a situation where if the government does decide it wants to disclose this vulnerability, it may have to figure out how it can legally do that. Does it have the right to disclose that or are those rights held by the company that discovered the vulnerability in the first place?


MONTAGNE: Right, this is very interesting, the idea being that the hackers would own a potentially valuable product here.


KNAKE: It’s something that I think we’re going to see intellectual property lawyers fight out over the next couple years because I think Apple certainly would say how can you own a vulnerability in our source code and in our software and in our devices? That seems a little bit off. But it’s certainly an area where we don’t have a very clear playbook.


MONTAGNE: Although couldn’t any tech company buy back the vulnerability itself?


KNAKE: Absolutely, and I think that’s been one thing that we’ve been, in the policy community, looking at very seriously is why don’t companies like Apple and Facebook and others who are very, very profitable – why aren’t they putting more money into purchasing vulnerabilities so they can be fixed? And I think the answer is these companies don’t want to create a situation in which they’re really being compelled not only to pay out millions of dollars but also to have to fix their software on an even faster basis than they already do.


MONTAGNE: It also feels, at this moment in time, a little like blackmail.


KNAKE: I think that is how many of the companies would characterize it.


MONTAGNE: You know, FBI director James Comey has said the government is considering whether to disclose to Apple the flaw or flaws in its phone. Aside from questions of whether they own the knowledge, what factors would be considered and who would be making this decision?


KNAKE: So at the top of the vulnerabilities equities process, you’ve got an equities review board, which is made up of senior members of every agency that might have an equity in this kind of case, right? So you would, for instance, have the FBI Counterterrorism Team advocating probably on behalf of retaining this vulnerability. On the other side of the FBI, you’d have their counterintelligence team probably saying, hey, we’ve got to protect all those iPhones 5s that have government information on them. We need to disclose this vulnerability to Apple. You would have other law enforcement agencies like the Secret Service at the table. You might have the Commerce Department if they thought they had an equity in it. So this team of people would come together and they’d look at a variety of questions and factors to determine whether they think, on balance, the vulnerability should be disclosed or should be retained.


MONTAGNE: Will we ever know exactly how this particular phone was hacked?


KNAKE: So this is an unusual case. Normally, I would say that there would be very little chance that if the government decides to disclose it, it will disclose anything more than what it knows to Apple and that we would never know that happened. In this case ’cause it’s become so public, I think it’s possible that the FBI might share details more broadly. So, yes, I think it is in fact possible that we may get to the bottom of what the vulnerability was and get solid assurance from Apple that they fixed it.


MONTAGNE: Rob Knake spent four years as the director of cyber security policy at the National Security Council in the Obama White House. Thanks very much for joining us.


KNAKE: Thank you.

A Rare Look Inside The ‘Gigafactory’ Tesla Hopes Will Revolutionize Energy Use

About 14 percent of the Gigafactory in Nevada has been built so far. At 5.8 million square feet, it will be a building with one of the biggest footprints in the world.

About 14 percent of the Gigafactory in Nevada has been built so far. At 5.8 million square feet, it will be a building with one of the biggest footprints in the world.

Tesla

Outside Reno, in Nevada’s high desert, Tesla is building what it says is the world’s largest battery factory. The Gigafactory, as it’s called, will churn out batteries for the company’s electric cars. But it’s also making something new — a battery for the home.

Tucked away in a dusty valley near Sparks, Nev., the Gigafactory is kind of like Willy Wonka’s chocolate factory: It’s mysterious, it’s big and few people have been inside.

Actually, “big” may not do it justice.

“It’s really hard to get a sense of scale. I mean, it’s huge,” JB Straubel, Tesla’s chief technical officer, says while standing on the roof of the factory — the 14 percent of the Gigafactory that’s been built, at least.

We’re looking down at a flat stretch of land where the rest of the Gigafactory — with an estimated price tag of $5 billion — will go.

Like Willy Wonka’s factory, there’s a lot of hype around this place. People have been caught sneaking onto the property to see what Straubel says, at 5.8 million square feet, will be a building with one of the biggest footprints in the world.

“I’m not a huge football fan, but I think it’s on the order of around 100 football fields,” he says.

Nevada beat out several states by offering an incentive package worth more than $1 billion. State lawmakers are watching like hawks for the economic benefits, such as making sure Nevadans make up a big part of the factory’s 6,000 workers.

Inside the factory, in room after room after room, workers are welding steel, pouring concrete and installing highly specialized machines, shrouded in plastic.

The production line at Tesla's Gigafactory is already operating for the Powerwall, a battery designed to store electricity from solar panels in average homes.

The production line at Tesla’s Gigafactory is already operating for the Powerwall, a battery designed to store electricity from solar panels in average homes.

Lauren Sommer/KQED

One room is filled with huge metal tanks, like an insanely large industrial kitchen. It’s where the raw materials are mixed together. In other rooms, the fully formed pieces of the battery, called the anode and cathode, are baked in huge ovenlike machines, several hundred feet long.

According to Straubel, the equipment in the factory will double the world’s capacity to make lithium-ion batteries. Tesla hopes to produce 35 gigawatt-hours of energy storage annually, which could supply 500,000 of its electric cars.

“It’s not just about building a lot more batteries but it’s about reducing the cost,” Straubel says.

Tesla is known for pricey electric cars, and batteries are a big part of the sticker price. And that, Straubel says, is why this factory is all about scale. Scaling up could drive down the cost of batteries 30 percent or more, he says. Battery packs in most electric cars are estimated to cost more than $10,000 today.

“Our vehicles can be more affordable. More people can have access to them,” Straubel says.

That’s the company’s goal with the new Model 3, Tesla’s first mass market car, announced last month. The Model 3 will start at about $28,000 after the federal tax credit.

“We have today over 325,000 reservations for Model 3, representing this enormous backlog of orders,” Straubel says.

Those are orders that Tesla can’t fill if this factory isn’t up and running.

One room over, part of the factory is running, but it’s making something else: the Powerwall. The flat battery, about 4 feet tall and 3 feet wide, is Tesla’s first battery for residences.

“If someone has solar on their house and they install a Powerwall, what this lets you do is store your surplus solar energy,” Straubel explains.

This is Tesla’s ultimate vision: an electric car in your driveway and a Powerwall — priced starting at $3,000 — in your garage. It’s a future free of fossil fuels, Straubel says.

Tesla is also making a larger version of these batteries called Powerpacks, about the size of a refrigerator, that can be used to store electricity at factories, industrial sites, or by electric utilities.

The Powerwall, a battery designed to store electricity from solar panels in average homes.i

The Powerwall, a battery designed to store electricity from solar panels in average homes.

Lauren Sommer/KQED


“That’s changing the transportation landscape. It’s changing the energy landscape. It’s changing the world,” Straubel says.

Severin Borenstein, an energy economist at the University of California, Berkeley, agrees that it would be “a game changer for reducing greenhouse gas emissions.” The question, he says, is whether consumers will buy into Tesla’s vision.

Take that $3,000 home battery. Electric rates in many states make it hard to actually save money storing your own electricity.

Some solar customers are paid by their electric utilities for the extra solar power they put onto the grid, a policy known as “net energy metering.” That creates little incentive to store solar energy at home.

A battery could help someone save money if his electricity costs a lot more at night than it does during the day. Borenstein says few states have those kinds of electricity prices.

“Average households are not going to get much or any value from these batteries,” Borenstein says.

Early adopters may not care, though.

“They’re people who like that and feel good about it and they’re mostly pretty darn rich,” he says.

Tesla CEO Elon Musk is betting that cheaper batteries will make everyone else want a home battery and electric car, too, which could finally lead the company to profitability.

“Is Elon Musk far-seeing and investing in the future?” Borenstein asks. “Or is he making big bets that could all collapse at once?”

The Gigafactory is exactly that gamble. If Tesla stays on schedule, it’ll be fully open in four years.

Listen To Wikipedia-Engineers Translate Edits Into Sound

We all know Wikipedia, the crowd-sourced compendium[kəm’pɛndɪəm] of online information. Most of the time we read Wikipedia entries, but we’re about to hear an audio interpretation of those pages and how they are edited. This comes to us courtesy[‘kɝtəsi] of our friends at The World According To Sound. It’s a podcast by Chris Hoff and Sam Harnett. Take a listen.

This is the sound of Wikipedia being edited.

 It’s a project made by Stephen LaPorte and Mahmoud[穆罕默德] Hashemi. They wrote a program that turns every edit of a Wikipedia entry into a sound. Whenever someone adds information, you hear a bell, and when they delete something, you hear a string plucked.

And the pitch[pɪtʃ] reflects the size of the edits, the lower the note, the larger the edit. There are several edits every second on Wikipedia, thousands every hour. You can hear and see them all in real time at listen.hatnote.com.

The World According to Sound is a podcast created by Chris Hoff and Sam Harnett.