结对编程
by Chris Cooney
克里斯·库尼(Chris Cooney)
结对编程的心理学 (The Psychology of Pair Programming)
最好的结对程序员表现出的行为和技巧。 (Behaviours and skills exhibited by the very best pair programmers.)
Dr. Sallyann Freudenberg is a software engineer and psychologist who has spent some serious time observing the behaviours of high performing software teams. Her blogs contain a wealth of information for any software professional looking to sharpen their skills.
Sallyann Freudenberg博士是一位软件工程师和心理学家,他花了很多时间观察高性能软件团队的行为。 她的博客为想要提高技能的任何软件专业人员提供了大量信息。
As an engineer with no psychology background whatsoever, I couldn’t help but think — this is some really, really good stuff. It’s accessible, easy to understand and clear. I thought… perhaps I’ve picked up the wrong career? Maybe I’m a psychologist! So I read a little Freud and oh my god the horror, so I’m definitely still an engineer and have no interest in psychology any more. Also I can’t look my mother in the eye.
作为一个没有心理学背景的工程师,我禁不住想-这是一些非常非常好的东西。 它易于访问,易于理解和清除。 我以为……也许我选错了职业? 也许我是心理学家! 因此,我读了一些弗洛伊德和我的天哪,恐怖片 ,所以我绝对仍然是一名工程师,对心理学不再有兴趣。 我也看不到我母亲的眼睛。
Anyway, after many hours of repetitive strain injury-inducing labour, here is what I have produced. A collection of tips, based on the work of Dr. Freudenberg. My hope is that you’ll use this as a primer, an appetiser if you will, before diving into Dr. Freudenberg’s work and developing a more full understanding. Let’s get started.
无论如何,经过数小时的重复性劳损诱导劳动,这就是我所产生的。 基于Freudenberg博士的工作的一些技巧。 我的希望是,在深入研究Freudenberg博士的工作并获得更全面的了解之前,您可以将其用作入门书籍和开胃菜。 让我们开始吧。
定期休息 (Take Regular Breaks)
Easy one to open up with. I know I sound like your mother when you were young. She warned you against square eyes. Well she was wrong about the square eyes thing but she was right about taking a damn break once in a while.
容易打开。 我知道我小时候听起来像你的母亲。 她警告你不要睁大眼睛。 好吧,她对方形眼睛的事情是错误的,但对偶尔休息一下是正确的。
Regular breaks are well understood in psychology. In the context of pair programming, they:
- Prevent context from building up too much. Breaks break things up. 防止上下文过多建立。 休息分手。
- Lower the cognitive load and enable longer overall pair programming sessions. 降低认知负担并启用更长的总体配对编程会话。
- Make you happier! 让您更快乐!
Of all the basic sins I see, this is the most common. Five hour meetings with no time budgeted for breaks. “Powering through” isn’t always the answer. Sometimes, going for a coffee or a beer (depending on how stuck you are) can provide the answer too. If you’re interested, there is a brilliant book about slack time that gives a much fuller answer to this topic.
在我看到的所有基本罪行中,这是最常见的。 五小时的会议,没有时间安排休息时间。 “助力”并不总是答案。 有时候,去喝咖啡或啤酒(取决于您被困的程度)也可以提供答案。 如果您有兴趣,那么有一本关于闲暇时间的精彩书籍 ,可以为您提供更全面的答案。
按下键盘,不要拿 (Push the keyboard, don’t take it)
The keyboard, in Dr. Freudenberg’s research, was the physical component of control. Engineers would pass the mouse around freely in Canada, but the keyboard was held sacred. In high performing pairs, the driver would volunteer control of the keyboard. It would never be taken. From this, we can glean a simple rule for both the driver and the navigator.
在科德宝博士的研究中,键盘是控制的物理组成部分。 工程师可以在加拿大自由传递鼠标,但是键盘是神圣的。 在高性能配对中,驾驶员将自愿控制键盘。 它永远不会被采取。 由此,我们可以为驾驶员和导航员收集一条简单的规则。
驾驶员-了解何时停车。 (The Driver — learn when to pull over.)
The example from Dr. Freudenberg’s research illustrates this.
Freudenberg博士研究的例子说明了这一点。
Example 1 (Anna is navigating, Ben is driving):
示例1(安娜在导航,本在驾驶):
Anna: “If you…..go to….”
安娜:“如果你……去……。”
Ben: (sliding the keyboard over to her) “(You) drive….it’s easier”.
本:(将键盘滑到她身上)“((您)开车……,这更容易”。
The driver is aware of the most effective way to communicate and is happy to relinquish control when needed. Don’t let your ego cling to the keys. Hand it over when necessary.
驾驶员意识到最有效的通信方式,并愿意在需要时放弃控制。 不要让你的自我执着于钥匙。 必要时移交给它。
导航器-不要失去权力。 (The Navigator — don’t disempower.)
When you’re watching, watch. Drop hints, be friendly, but don’t force control out of the driver’s hands. It creates resentment. Treat that keyboard carefully.
当您观看时,观看。 放下提示,保持友善,但不要强行将控制权移出驾驶员的手。 它会引起怨恨。 小心对待该键盘。
The driver is often seen as the position of power in the pair, but the navigator has the ability to derail the whole exercise by hijacking the keyboard when things get tricky. With great power comes great responsibility.
驾驶员通常被视为一对中的动力位置,但是导航器具有在事情变得棘手时通过劫持键盘来破坏整个运动的能力。 拥有权利的同时也被赋予了重大的责任。
有画的地方。 (Have somewhere to draw.)
A whiteboard is the gold standard here. A nice, big, clear space to draw all over. Words are great and all but nothing beats a bunch of wonky boxes and not so straight lines.
白板是这里的黄金标准。 一个不错的,宽敞而又清晰的空间,可以绘制所有内容。 文字很棒,但几乎没有什么能击败一堆摇摇欲坠的盒子,而不是直线。
In Dr. Freudenberg’s research, a key finding was the use of scribbled on diagrams in high performing pairs. The creative act of writing the diagram sparks thoughts and jogs memories. They were far more powerful than pre-existing diagrams, which seemed to be more useful when seeking a holistic view of multiple teams and systems.
在Freudenberg博士的研究中,一个关键发现是在高性能对中对图表进行了涂抹。 编写图表的创造性行为激发了人们的想法并缓和了记忆。 它们远比现有的图表强大,当寻求多个团队和系统的整体视图时,这些图表似乎更有用。
Sometimes things are difficult to convey without a hastily drawn picture. If you don’t have a whiteboard, use a notepad. In one example, Dr. Freudenberg observed someone tracing a diagram with their finger. Drawing sparks joy people!
有时,如果没有草草画出的图片,事情很难传达。 如果您没有白板,请使用记事本。 在一个示例中,弗洛伊登贝格博士观察到有人用手指在画图。 绘画激发人们欢乐!
邀请自发的外部帮助 (Invite spontaneous outside help)
So there you are, working through a problem. An API that needs consuming and saving into a database. You debate, discuss and start writing. Nothing is working and you don’t know why, but if you can just focus… just a little longer. A few more uninterrupted hours.
这样您就可以解决问题了。 需要消耗并保存到数据库中的API。 您进行辩论,讨论并开始写作。 什么都没做,你也不知道为什么,但是如果你能集中精力……再等一会儿。 再连续几个小时。
Then… Bill from the payments team leans over and asks you about something you just said.
然后...付款团队的Bill俯身询问您刚才所说的话。
但是比尔有一个很好的观点。 (But Bill has got a good point.)
“Hey, that endpoint actually uses a different model to the other APIs”, Bill mutters, acutely aware of the thunderous look in your eyes. You could be mad at Bill, but the truth is, he was right to stop you. You were about to write some broken-ass code. Is Bill the enemy? No. Your way of working is.
“嘿,那个端点实际上使用了与其他API不同的模型”,Bill喃喃自语,敏锐地意识到了您眼中的震撼人心。 您可能会对比尔生气,但事实是,他阻止了您。 您将要编写一些破烂的代码。 比尔是敌人吗? 不,您的工作方式是。
Interruptions are going to happen, especially when you’re building the wrong stuff. The truth is, Bill just saved your bacon. In Dr. Freudenberg’s research, this kind of open communication was welcomed by high performing pairs. It increased knowledge transfer and made for a much more efficient pairing.
中断将发生,尤其是当您构建错误的内容时。 事实是,比尔刚刚保存了您的培根。 在科德宝博士的研究中,这种开放式的交流受到了高性能配对的欢迎。 它增加了知识转移,并使配对更加有效。
So go apologise to Bill. He just saved you a bunch of time and fresh grey hairs.
因此,向比尔道歉。 他只是为您节省了大量时间和新鲜的白发。
保留上下文 (Preserve Context)
The problem with the previous scenario was the context. Maybe Bill could use some personal boundaries training, but if it wasn’t Bill, you know it’d be Sandra from the Ops department. Bloody Sandra…
前一种情况的问题是上下文。 也许比尔可以使用一些个人界限培训,但是如果不是比尔,那您将是运维部门的桑德拉。 血腥的桑德拉…
That complex clockwork of context in your minds eye is only available in your living room. In the workplace, you’re gonna need to talk and not always on your own terms. Dr. Freudenberg explains that software engineers need to operate at multiple levels of abstraction at the same time, constantly flitting in and out of levels of detail. This creates problems when building up large, complex images in your mind. How do the high performing pairs deal with this?
在您眼中,复杂的时钟发条仅在您的客厅中可用。 在工作场所,您将需要交谈,而不必总是按照自己的意愿。 Freudenberg博士解释说,软件工程师需要同时在多个抽象级别上进行操作,不断地跳入和跳出细节级别。 在您脑海中构建大型复杂图像时,这会产生问题。 高性能配对如何处理?
清单,你这傻鹅 (Lists, you silly goose)
The key is to keep focused on what you’re doing. When you find new things, put that down in writing. The items in the list form little flags, reminders of questions and facts you’ve unearthed. This means you can remain focused on the problem at hand and not lose track of the discoveries you’ve made along the way.
关键是要继续专注于自己在做什么。 当您发现新事物时,请将其写下来。 列表中的项目会形成一些小标志,提醒您所发掘的问题和事实。 这意味着您可以专注于眼前的问题,而不会迷失沿途所做的发现。
The next time James from HR comes in to tell you to stop high fiving strangers in the lobby, your context won’t be obliterated. You might be slowed down for a moment, but glance down at those sweet lists. You’re back in the matrix.
HR的James下一次告诉您在大厅停止击掌的陌生人时,您的情况将不会消失。 您可能会慢下来一会儿,但请瞥一眼那些甜蜜的清单。 您又回到了矩阵中。
关于清单的另一件事 (And one more thing about lists)
Before you go all sharpie-pro on your checklist, Dr. Freudenberg has one more finding. More often than not, lists are not revisited. They’re written and discarded. It’s essentially just a bit of ephemeral storage for your brain. Don’t worry about neatness. Worry about getting your ideas on to something more permanent than the jelly in your head and protecting the current object of your focus.
在将所有Sharpie-Pro列入清单之前,Freudenberg博士还有另一个发现。 通常,列表不会被重新访问。 它们被写入并被丢弃。 从本质上讲,这只是大脑的短暂存储。 不用担心整洁。 担心将您的想法转移到比果冻更永久的东西上,并保护您当前关注的对象。
与标签小组配对分担负担。 (Share the burden with tag team pairing.)
Coffee number seven. This damn test won’t go green, no matter what you try. You decided to swap when it did, so you’ve been driving for well over an hour. You’re tired, your partner is bored and progress has all but stopped. Soon, you’ll go home and drink whiskey like any 90s American action hero.
七号咖啡。 无论您如何尝试,该死的测试都不会成功。 您决定在换车时换车,因此您已经开车了一个多小时。 您很累,伴侣很无聊,进步几乎停了下来。 很快,您将回家,像任何90年代的美国动作英雄一样喝威士忌。
We’ve seen this a thousand times. Individuals investing too heavily in the problem and refusing to review their goals. Often it’s pride, sometimes it’s sheer belligerence. To combat this, Dr. Freudenberg found that as well as specified goal points, high performing pairs would “tag” one another in.
我们已经看过一千遍了。 个人在问题上投入过多,拒绝审查自己的目标。 通常这是骄傲,有时是纯粹的好战。 为了解决这个问题,弗洛伊登伯格博士发现,除了指定的目标点以外,高绩效的配对也会“互相标记”。
This makes intuitive sense, right? In the ring, if Stone Cold Steve Austin is growing tired, you know he is gonna tag The Rock in (my wrestling knowledge is pretty out of date). If you’re running out of juice, it should be a legitimate reason to change drivers. Don’t trip and fall into the death march.
这很直观,对吧? 在圆环中,如果S 音Cold Steve Austin越来越疲倦,那么您就知道他会给The Rock加上标签(我的摔角知识已经过时了)。 如果您的果汁用完了,那就应该换驱动程序了。 不要绊倒,跌入死亡行军。
Follow Dr. Freudenberg on Twitter! I do and you should too. Also, the source material for this article (including all relevant academic sources) is available on Sal’s wonderful blog.
在Twitter上关注Freudenberg博士! 我愿意,你也应该。 另外,可在Sal的精彩博客上获得本文的源材料(包括所有相关的学术资源)。
While you’re at it, follow me on twitter. I’m regularly blogging about the work of other, smarter people.
当您在浏览时, 在Twitter上关注我 。 我经常在博客中谈论其他更聪明的人的工作。
翻译自: https://www.freecodecamp.org/news/the-psychology-of-pair-programming-86cb31f9abca/
结对编程