极限编程(Extreme Programming)—实践

来源:互联网 发布:云计算项目经理招聘 编辑:程序博客网 时间:2024/04/28 00:56

极限编程(Extreme Programming)—实践

march-bird lucian yjf taopin wl jazz韩伟 nullgate Simon[AKA](转载自cutter.com)    2003年09月15日

  Practices

  实践


  One thing to keep in mind is that XP practices are intended for use with small, co-located teams. They therefore tend toward minimalism, at least as far as artifacts other than code and test cases are concerned. The presentation of XP's practices have both positive and negative aspects. At one level, they sound like rules -- do this, don't do that. Beck explains that the practices are more like guidelines than rules, guidelines that are pliable depending on the situation. However, some, like the "40-hour week," can come off as a little preachy. Jeffries makes the point that the practices also interact, counterbalance, and reinforce each other, such that picking and choosing which to use and which to discard can be tricky.

  应记住的一件事情就是我们应倾向于在小型的, 局部的团队中运用XP。除了代码与测试用例外, 尽量减少有些的影响。XP的实践既有正面的表现,也有负面的。在某些方面看来,他们听起来就像一堆规则,要做这个,不要做那个。对此Beck解释道, 与规则相比, XP更像是指导方针,一个灵活的依赖于具体环境的开发方针。但是诸?quot;每周工作40小时"等看起来可能会感觉续续道道。Jeffries使得实践也会互相作用的,平衡,互相加强。以至于挑选使用的同丢弃的都是棘手的事情。
  
  The planning game. XP's planning approach mirrors that of most iterative RAD approaches to projects. Short, three-week cycles, frequent updates, splitting business and technical priorities, and assigning "stories" (a story defines a particular feature requirement and is displayed in a simple card format) all define XP's approach to planning.

  计划的制定:XP中关于制定计划的实现方法中可以反映出大多数迭代式RAD项目的特点。短期的,每三周为一个循环,频繁地更新,按优先级划分任务与技术, 分配stories(一个story定义了一个特殊的功能需求并以一种简单的方式记录在卡片上),所有的这些就是构成了XP中的计划。

  Small releases. "Every release should be as small as possible, containing the most valuable business requirements," states Beck. This mirrors two of Tom Gilb's principles of evolutionary delivery from his book Principles of Software Engineering Management: "All large projects are capable of being divided into many useful partial result steps," and "Evolutionary steps should be delivered on the principle of the juiciest one next."

  小版本:"每个版本应该尽可能的小,而且包含最有商业价值的需求",Beck如是说。这也反映了Tom Gilb在他的<软件工程管理原则>书中提到的关于渐进式发布的两点:"所有的大的项目都可以被分为局部的, 有用的小的步骤"以及"进化的步骤会传递到下一级。"

  Small releases provide the sense of accomplishment that is often missing in long projects as well as more frequent (and more relevant) feedback. However, a development team needs to also consider the difference between "release" and "releasable." The cost of each release -- installation, training, conversions -- needs to be factored into whether or not the product produced at the end of a cycle is actually released to the end user or is simply declared to be in a releasable state.

  小型版本的发布意味着具有在大型项目中经常缺少的频繁的反馈的实现.。 然而,一个开发小组当然需要考虑到"发布"同"可发布"的不同。无论是否是最终的版本发布还是一个简单的可发行版本的发布, 都需要付出安装,培训,转化等代价。

  Metaphor. XP's use of the terms "metaphor" and "story" take a little wearing in to become comfortable. However, both terms help make the technology more understandable in human terms, especially to clients. At one level, metaphor and architecture are synonyms -- they are both intended to provide a broad view of the project's goal. But architectures often get bogged down in symbols and connections. XP uses "metaphor" in an attempt to define an overall coherent theme to which both developers and business clients can relate. The metaphor describes the broad sweep of the project, while stories are used to describe individual features.

  隐喻:在XP中"隐喻"以及"story"的使用可能会让人有一点不舒服。但是,这些术语的使用可以帮助我们以一种更人性化的方式加以理解,尤其是对客户而言。从某种程度上来说,隐喻同体系结构是同意语――他们都着重于从全局描述一个项目。但是体系结构经常会陷于符号与连接的泥潭。而XP使用"隐喻"定义一个从开发者到商业客户都可联系的全面一致的主题。隐喻用于描述项目全面的面貌,而Story用于描述个别具体的特征。

  Simple design. Simple design has two parts. One, design for the functionality that has been defined, not for potential future functionality. Two, create the best design that can deliver that functionality. In other words, don't guess about the future: create the best (simple) design you can today. "If you believe that the future is uncertain, and you believe that you can cheaply change your mind, then putting in functionality on speculation is crazy," writes Beck. "Put in what you need when you need it."
  
  简单的设计:简单的设计包含两个部分。一,为已定义的功能进行设计,而不是为潜在地未来可能的功能进行设计。二,创建最佳的可以实现功能的设计。换句话说,不用管未来会是怎样,只创建一个目前为止可以实现的最好的设计。"如果你相信未来是不确定的,并且你相信你可以很方便的改变你的主意的话,那么对未来功能的考虑是危险的。"Beck写到。"只有在你真正需要的时候才去做"

  In the early 1980s, I published an article in Datamation magazine titled "Synchronizing Data with Reality." The gist of the article was that data quality is a function of use, not capture and storage. Furthermore, I said that data that was not systematically used would rapidly go bad. Data quality is a function of systematic usage, not anticipatory design. Trying to anticipate what data we will need in the future only leads us to design for data that we will probably never use; even the data we did guess correctly on won't be correct anyway. XP's simple design approach mirrors the same concepts. As described later in this article, this doesn't mean that no anticipatory design ever happens; it does mean that the economics of anticipatory design changes dramatically.

  在二十世纪八十年代,我发表了一篇有关自动化资料管理的文章"实际的同步数据"文章的意思是说数据的质量是使用功能,不是捕捉与存储。此外,我说数据如果不是很系统的使用便会变坏。数据质量是系统使用的功能,不是可预料的设计。无论预期的对还是错,试着设计一个我们从来都不会用到的数据,最终结果很可能我们一次也不会用到它们。XP的简单设计方法反映了相同的观点。如在本文后来所描述的那样,这并不意味着不需要预测,而是说为预测的内容所做的设计一旦发生变化,其导致的代价是十分巨大的。

  Refactoring. If I had to pick one thing that sets XP apart from other approaches, it would be refactoring -- the ongoing redesign of software to improve its responsiveness to change. RAD approaches have often been associated with little or no design; XP should be thought of as continuous design. In times of rapid, constant change, much more attention needs to be focused on refactoring. See the sections "Refactoring" and "Data Refactoring," below.

  重构:如果我不得不找出一个能够将XP和其他方法区别开来的东西那就是重构――不断的软件再设计以改进它对于变化的反应。RAD方法常常很少甚至根本不与设计相关;XP应当被看作持续设计。当变化既快而且频繁的时候,应投入更多的精力于重构之上。参见下面的"重构"和"数据重构"部分。

  Testing. XP is full of interesting twists that encourage one to think -- for example, how about "Test and then code"? I've worked with software companies and a few IT organizations in which programmer performance was measured on lines of code delivered and testing was measured on defects found -- neither side was motivated to reduce the number of defects prior to testing. XP uses two types of testing: unit and functional. However, the practice for unit testing involves developing the test for the feature prior to writing the code and further states that the tests should be automated. Once the code is written, it is immediately subjected to the test suite instant feedback.

  测试:XP充满发人深思的有趣的难题。例如:什么是"先测试后编码"?我曾经同软件公司和一些IT机构一起工作,在那儿是通过代码的行数来对程序员的绩效加以考核,而测试的绩效则是通过发现的缺陷的数量来考核的。这两种方法都不能鼓励减少测试前产生的缺陷的数量。XP使用两种测试:单元测试和功能测试。单元测试要求在写代码之前就开发出相应功能的测试方法,并并测试应当是自动化的。代码一完成,它就被立即用有关测试集加以测试,从而能立即得到反馈。

  The most active discussion group on XP remains the Wiki exchange (XP is a piece of the overall discussion about patterns). One of the discussions centers around a lifecycle of Listen (requirements) Test Code Design. Listen closely to customers while gathering their requirements. Develop test cases. Code the objects (using pair programming). Design (or refactor) as more objects are added to the system. This seemingly convoluted lifecycle begins to make sense only in an environment in which change dominates.

  最活跃的XP讨论组仍然是Wiki exchange(XP是关于pattern总体讨论的一部分),其中的一个讨论围绕听取(需求)-> 测试 -> 代码 -> 设计的生命周期。贴近客户聆听并收集他们的需求。开发测试用例(test cases)。完成对象编码(使用配对编程)。当更多对象被加入系统时进行设计(或重构)。这个看起来混乱不堪的生命周期仅仅在经常变化的环境下才有意义。

  Pair programming. One of the few software engineering practices that enjoys near-universal acceptance (at least in theory) and has been well measured is software inspections (also referred to as reviews or walkthroughs). At their best, inspections are collaborative interactions that speed learning as much as they uncover defects. One of the lesser-known statistics about inspections is that although they are very cost effective in uncovering defects, they are even more effective at preventing defects in the first place through the team's ongoing learning and incorporation of better programming practices.

  配对编程:软件(还是直接用Inspection为好?)(也称审查或走查)也是被广为接受(至少在理论上)和有效度量的少数软件工程实践之一。在最好情况下,Inspection这种协同交互的检查能够加速学习,同时发现缺陷。一个较少被知道的关于Inspection的统计数据是尽管它在发现缺陷方面非常有效,但通过团队对于好的开发实践持续的学习和协作,可以更好的在第一时间预防缺陷。

  One software company client I worked with cited an internal study that showed that the amount of time to isolate defects was 15 hours per defect with testing, 2-3 hours per defect using inspections, and 15 minutes per defect by finding the defect before it got to the inspection. The latter figure arises from the ongoing team learning engendered by regular inspections. Pair programming takes this to the next step -- rather than the incremental learning using inspections, why not continuous learning using pair programming?

  一家我工作过的软件公司客户引用一个内部研究结果,表明在测试阶段发现一个缺陷需15小时,在Inspection阶段发现一个缺陷则需2-3小时,而在Inspection之前发现缺陷只需15分钟。后面的数据来自于产生于常规审查的持续的团队学习。配对编程将这个带入下一步――与其用Inspection来递增式学习,为什么不用配对编程来学习呢?

  "Pair programming is a dialog between two people trying to simultaneously program and understand how to program better," writes Beck. Having two people sitting in front of the same terminal (one entering code or test cases, one reviewing and thinking) creates a continuous, dynamic interchange. Research conducted by Laurie Williams for her doctoral dissertation at the University of Utah confirm that pair programming's benefits aren't just wishful thinking (see Resources and References).

  "配对编程是两个人试图同时编程和理解如何更好编程的一种对?quot;,Beck写道。让两个人同时坐在一台终端前面(一个人敲代码或测试用例,一个人审查和思考)产生一种持续的、动态的交流。Williams在犹他大学进行的博士论文研究证明了配对编程不仅仅是一种美好的想法而且确有实效。(参见资源和参考)

  Collective ownership. XP defines collective ownership as the practice that anyone on the project team can change any of the code at any time. For many programmers, and certainly for many managers, the prospect of communal code raises concerns, ranging from "I don't want those bozos changing my code" to "Who do I blame when problems arise?" Collective ownership provides another level to the collaboration begun by pair programming.

  代码共享:项目组中的每个人都可以在任何时候修改其他项目成员的代码,这就是XP中所定义的代码共享。。对许多程序员以及经理而言,,共有代码的想法会引起一些疑虑,诸如"我不想让那些笨蛋改我的代码","出现问题我应该怪谁?"等等。共享代码从另一个层面提供了对配对编程中协作的支持。

  Pair programming encourages two people to work closely together: each drives the other a little harder to excel. Collective ownership encourages the entire team to work more closely together: each individual and each pair strives a little harder to produce high-quality designs, code, and test cases. Granted, all this forced "togetherness" may not work for every project team.

  配对编程鼓励两个人紧密协作:每个人促使另一个更加努力以图超越。共同所有鼓励整个团队更加紧密协作:每个个人和每个双人更努力生产高质量设计、代码和测试集。当然,所有这些强迫的"共同"不一定对所有的项目组适用。


  Continuous integration. Daily builds have become the norm in many software companies -- mimicking the published material on the "Microsoft" process (see, for example, Michael A. Cusumano and Richard Selby's Microsoft Secrets). Whereas many companies set daily builds as a minimum, XP practitioners set the daily integration as the maximum - opting for frequent builds every couple of hours. XP's feedback cycles are quick: develop the test case, code, integrate (build), and test.
  
  经常集成:每日构造(build)在许多公司已经成为规范,模仿有关"微软"流程的出版物上的东西。(参见,例如,Michael A. Cusumano和Richard Selby的Microsoft Secrets)许多公司将每日编链作为最小要求,XP实践者将每日集成作为最大要求,选择每两个小时一次的频繁编链。XP的反馈周期迅速:开发测试集、编码、集成(编链)和测试。

  The perils of integration defects have been understood for many years, but we haven't always had the tools and practices to put that knowledge to good use. XP not only reminds us of the potential for serious integration errors, but provides a revised perspective on practices and tools.

  对于集成缺陷危险的认识已有多年了,但我们并不是总能拥有相应工具和时间将这些知识好好用起来。XP不仅提醒我们有可能有严重的集成错误,而且从实践与工具的角度提供了一种新的认识。

  40-hour week. Some of XP's 12 practices are principles, while others, such as the 40-hour practice, sound more like rules. I agree with XP's sentiments here; I just don't think work hours define the issue. I would prefer a statement like, "Don't burn out the troops," rather than a 40-hour rule. There are situations in which working 40 hours is pure drudgery and others in which the team has to be pried away from a 60-hour work week.

  每周只干40小时:XP有12条实践的基本原则,但是有时候,比如象每周只干40小时的原则,听起来更象规则。我同意XP中的观点。只是不认为有必要硬性规定工作小时数。相比起来,我更喜欢一句类似于"不要把部队烧光"的话。在一些情况下,工作40小时太劳累,而在另外一些组里,甚至需要一周60个工作时。

  Jeffries provided additional thoughts on overtime. "What we say is that overtime is defined as time in the office when you don't want to be there. And that you should work no more than one week of overtime. If you go beyond that, there's something wrong -- and you're tiring out and probably doing worse than if you were on a normal schedule. I agree with you on the sentiment about the 60- hour work week. When we were young and eager, they were probably okay. It's the dragging weeks to watch for."

  Jeffries提供了关于加班的更多思索:"我们说的是加班被定义为我们不想在办公室的时候呆在办公室。而且你不应当加班超过一周。如果你超过了,就有什么东西出了问题――你过于劳累,有可能比你按时下班干的还差。我同意你关于60工作时一周的感受。在我们年轻和满身干劲的时候,这也许没问题。值得注意的是拖沓的一周又一周。"

  I don't think the number of hours makes much difference. What defines the difference is volunteered commitment. Do people want to come to work? Do they anticipate each day with great relish? People have to come to work, but they perform great feats by being committed to the project, and commitment only arises from a sense of purpose.

  我不认为一周的工作时间会造成大的差别。决定区别的是自愿的贡献。人们愿意来工作吗?他们对每一天都充满干劲吗?人们必须来工作,但是他们通过投入项目来创造巨大成就,而投入仅仅产生于目标感。

  On-site customer. This practice corresponds to one of the oldest cries in software development -- user involvement. XP, as with every other rapid development approach, calls for ongoing, on-site user involvement with the project team.

  现场客户:这就对应到了最初软件开发时所提出的问题――用户参与。XP,同其他的快速开发一样,要求客户在现场持续地参与到项目组中。

Coding standards. XP practices are supportive of each other. For example, if you do pair programming and let anyone modify the communal code, then coding standards would seem to be a necessity.

  编码标准:XP实践相互支持。例如,如果你进行配对编程并让他人修改共有代码,那么编码标准看起来就是必须的。

原创粉丝点击