|
作者 Robert C. Martin Rational 白皮书 Overview 概述 ------------------------------------------------------------------------------ Pairing, a brief description 双人编程简述 Pair Programming is a technique whereby software on a project is written by pairs of programmers. Each pair works together at a single workstation. One member of the pair drives the workstation while the other looks on, carefully watching the code being produced. The driver is thinking tactically, concerned for the line of code he is currently writing. The observer is validating syntax and is thinking strategically about the whole program. They trade these roles frequently and the resulting code is written faster than if by a single person and has fewer defects. Moreover, the code is intimately known by at least two developers. 双人编程指在一个项目中由两个程序员编写一个软件的技术.每两人在同一台机器上工作,其中一人操作机器的同时另一个在旁边仔细看着代码被编写出来.操作者从战术上关心当前自已在编写的每一行代码,观察者确认语法规范,并从战略上考虑整个程序.他们频繁地交换彼此的角色,并且更快地编写出比单人编写更少错误的代码.并且,这些代码至少被两个以上的开发者所熟悉。 The case for pairing 双人编写的案例 Consider a typical code review session. A module that required eight hours for one person to develop is reviewed for one hour by eight people. The net result is that 16 person-hours are spent on the module. However, the reviewers cannot spend the needed time to become familiar with the code and their review is fairly shallow. A single developer is intimately familiar, but perhaps too familiar to find the bulk of the defects. 让我们观察一下一个典型的代码评审过程,一个模块要求一个人花八个小时开发,评审需要八个人花一个小时,最终结果是这个模块花了16个人小时.然而,评审者并不能花费所需的时间对该代码达到熟悉的程度,因此他们的评审是相当浅薄的,一个单独的程序员对此倒是相当熟悉,但是反而会因为太熟悉而对里面的大多错误视而不见。 Contrast this with the practice of pair programming. If the module requires eight hours for the pair to develop, a total of 16 person-hours will be expended. However, in this case, two developers will have intimate knowledge of the code. The defects hidden from one developer will be visible to the other. 对比如果对于双人编程,如果一个模块要求八个小时,同样花费了16个人小时,然而,两个程序员对该代码是同样熟悉的,一个错误对于某人而言是视而不见,而对于另一个却显而易见。 The case for pair programming is simple, but the repercussions are subtle and far reaching. Pair programming is simply a much more effective way to write and review code. With two people intimately familiar with a module, far fewer defects will be written into the code. The code will have a better structure and intimate knowledge of it will be in twice as many brains. If these were the only benefits they would be sufficient, but the act of pairing provides still more benefits. 双人编程看来简单,但是影响却是微妙而深远,双人编程是一个简单而更有效的编码和评审的方法。由于由两个人用紧密合作的方式编码,更少的错误被写入代码中,代码会更有更好的结构并且被两人所熟悉。双人编程仅此优点就已足够使用,但实际上可得到的好处远不止于此。 Pairs are more courageous: What a single programmer might be afraid to try, a pair will have the courage to attempt and the skill to evaluate. 双人编程更有勇气:单个程序员可能会怯于尝试,而两个人会有勇气去尝试和技巧评估(theskill to aluate.)。 Pairing fosters teamwork: Since modules are not written by a single person the code becomes the property of the team, rather than of a particular developer. 双人编程可以促进团队合作:因为模块不是一个人写的,代码是整个团队的财产,而不是某个开发者的。 Pairing fosters the spread of knowledge: The more developers who pair with each other, the more the knowledge of the system diffuses through the whole team. The result is a team whose members are familiar with all of the system rather than each member knowing only their one particular part. 双人编程促进了知识的传输:越多的开发者互相配对编码,系统的知识越能传输到整个团队,结果是每个团队成员都熟悉整个系统,而不是每个成员只了解他们所写的那部分。 Pairing promotes productivity: A person programming alone goes through bursts of energy followed by periods of relative inactivity. Pairs pace each other. When one gets tired, they swap roles. They manage to keep the intensity turned on for much longer than a single person can usually tolerate. 双人编程提高了生产力:一个单独的程序员会突然精力爆发,然后却是周期性的呆滞(inactivity)。双人可以协调步调,当其中一个劳累时,他们可以调换角色,他们会设法保持一个持续的强度,而这种强度不是单个人可以吃得消的。 Pairing is fun: Working with another developer is educational, stimulating, and just plain fun. Pairing increases job satisfaction and overall morale. 双人编程充满乐趣:和另一个开发者工作富有教育性,充满刺激和乐趣。提高了工作满意度和全面的士气。 The Practice 实践 ------------------------------------------------------------------------------ Pairing 配对 Pairing begins when the developer responsible for a task asks someone else for help. The rule is: when asked, you must say yes. This does not mean you have to immediately stop what you are doing. Rather it means that you must negotiate a time when you can offer that help and another time when you can get help in return. 双人编程开始于负责某个任务的程序员寻求他人的帮助。原则是:有人来问,你必须说是,不过这不意味着你要马上停下你在做的工作,而是说,可以商定某个时间帮忙,而在另一个时间让对方帮你的忙。 The pair partner does not assume responsibility for the task. That responsibility remains with the task owner. Nor does the pair partner commit to staying with the owner until the task is complete. The pair partner only commits to help. 双人编程的拍档者不对所做的任务承担责任,责任由负责任务的那个程序员承担,,拍档者直到任务完成也不会承诺与任务负责人共同负担任务的责任,只是承诺会帮忙。 One member of the pair becomes the driver, while the other looks on. The driver types in the code, runs the compiler, runs the unit tests, and so forth. The watcher examines each keystroke, each command, each test result, and offers help and suggestions. Both parties are engaged at all times. 双人编程中的某个成员成为操作者,同时另一个作为观察者。操作者敲代码,编译,做单元测试,观察者检查每一次敲击,每一个命令,每次测试的结果,并提供帮助和建议,整个时间里两边都同样的忙碌。 Sometimes the driver will know best what to do, and the watcher will simply be following along. At other times, the watcher will dictate what to do to the driver. Sometimes the driver will get frustrated and will hand the keyboard to the watcher,thereby switching roles. Other times, the watcher will ask for the keyboard and switch roles. this will happen many times in a pairing session. 有时,操作者知道该如何做到最好,这时观察者就只是随着思路走就行了。反之,观察者可以指示操作者该如何做。有时操作者会思路阻碍做不下去,键盘交给观察者,两者便换了角色。在整个编码过程中,观察者会主动要求键盘输入,从而交换角色,这种情况是经常发生的。 Changing pairs 交换配对 Pair partners are not long term. A typical pairing session will last about half a day. Either partner can opt out of the pair for any reason. When this happens, the owner of the task must find another pair partner. This may mean that it is time for the task owner to pay back a favor to someone who paired with him or her last week. On the other hand, perhaps he or she should ask someone with the right experience to help with a particularly sticky problem. 双人编程的两个拍档不是长期合作的。一个典型的双人编程会持续大约半天,其中每个拍挡可以以任何理由要求重新选 | |
| ACCP 的难点解释 编程菜鸟成长记:梦想的脚步向我走近 北大青鸟:做暖IT职业教育市场 北大青鸟APTECH:按企业模式经营自己 ACCP, 美好未来的捷径 关于ACCP跳级考试的规定 北大青鸟APTECH再获大奖 办学思路闪耀高峰论… 北大青鸟APTECH创精品 学习ACCP的心得体会 北大青鸟APTECH2003抓管理 ,做IT精品教育 |
| 文章评论 | |||