|
Five Lessons You Should Learn from Extreme Programmingby chromatic, author of Extreme Programming Pocket Guide07/31/2003 |
- Code for Maintainability
- Know Your Status
- Communicate Early and Often
- Do Things That Matter
- Fix Your Most Important Problem First
Every so often, a new idea strikes software development. For awhile, it was structured programming. Object-oriented programming entered the fray. Now ideas like Six Sigma, CMM, UML, and XML databases all promise to make software more reliable, easier to write, and less expensive.
It's rare that any one idea applies to every facet of the software industry and it's unlikely that any single approach will be the last advice you'll ever need. Wise developers and managers ask, though, "What could I learn from this new idea? How can I make my work simpler, more effective, or more enjoyable?"
Extreme Programming (XP) is yet another popular idea gaining press. It adapts several of the best ideas from the past decades of software development. Whether or not you adopt XP, it's worth considering what XP teaches. In no particular order, here are five lessons you should learn from Extreme Programming.
Code for Maintainability
If there's a single driving goal behind XP, it's to keep the cost of change low by producing code that's easy to change. Change isn't your enemy. Perfect code isn't your goal. Your goal is to meet the customer's current needs while making it as easy as possible to meet the customer's future needs when they become known.
The first order of business on any new XP project is to get working code to the customer as quickly as possible without compromising on quality or discipline. This delivery should take place within a few weeks. The software may do very little, but it should demonstrate an actual business value and it should follow the XP rules for simplicity and provability.
Rather than attempting to get something out the door as the final, no-kidding-this-time deadline approaches, XP developers deliver new versions of the software regularly and frequently. A three-week iteration cycle is a popular rate. Instead of waiting for large migrations a few times a year, the software is delivered and improved upon every few weeks in smaller chunks. This is achieved, in part, by working in small steps but also by coding in a maintainable way.
Effective Simplicity
One of XP's catchphrases is "Do the Simplest Thing That Could Possibly Work." Solve the problem as simply as possible to get the job done correctly. Don't spend time creating a generalized solution (or worse, a generalized framework) if you don't need it yet.
This is hard to accomplish in practice; it's easy to play the "what-if" game and add in features you think you will need in the future. XP alleviates this with its emphasis on test-driven development and on constant customer communication. The customer has the final say over what's really necessary and what's superfluous.
This is a difficult skill to cultivate and a difficult skill to master. It's easy to confuse simplicity with baby coding or reinventing the wheel. While simplicity in one case may mean not adding a relational database backend yet, in another case it may mean reusing code from another project. However you achieve simplicity, adding features only when you actually need them often makes your software easier to change in the future.
Refactoring
XP has helped popularize refactoring—revising existing code to be cleaner and simpler while leaving its behavior unchanged. While practicing extreme simplicity may produce simple but sprawling code without a clear, coherent design, disciplined refactoring returns the code to its simplest and most effective possible form. One is simplicity of implementation. The other is simplicity of design.
If you add only the code you need only when you need it in the simplest way that could possibly work, you will often see a better design emerge than if you'd planned everything from the beginning. In an environment where your needs and goals change often, it is easier to be flexible by starting and staying simple than to try to plan ahead for every possible contingency.
Refactoring simplifies your code's design level. You do need some way of making sure you haven't broken anything, though that's another lesson.
Code Reviews
XP recommends pair programming for all important code. One of the biggest benefits of this pairing is continual code review. No matter how brilliant, talented, and experienced your developers, they won't always write the most perfect possible code. That's the idea behind refactoring. Why stop there, though? Instead of refactoring code someone else wrote without telling him, you could review each other's code, explain the changes you'd each make, and see if there's an even better approach.
A code review should ask several questions.
- How well are you adhering to the team standards?
- Did you overlook any possible flaws?
- Is there other code you could reuse?
- Could the code be simpler?
- Does it solve the problem it's supposed to solve?
Effective reviews share knowledge. It's often easier to learn what's going on in other parts of the code by walking through it with the author and seeing what everyone else is working on. Reviews also often spread new techniques through the team.
Know Your Status
One of the hardest questions to answer in any software project is, "When will it be finished?" A few programmers can get away with "When it's finished." The rest of us aren't so lucky.
There are ways to know how far you're along and if and how far you've backtracked. They don't require lots of paperwork or charts. They just need a little discipline and a little more customer involvement.
Programmer Tests
Programmer tests are written by programmers. XP suggests a practice called Test-Driven Development, where code is written only when prompted by a failing test. In other words, to add a feature, you write tests for that feature, one at a time, and write only the code necessary to pass those tests, one step at a time.
This is sometimes painful to start, but it has two wonderful effects. First, it builds up a comprehensive test suite with a fraction of the pain you'd experience writing the tests after the fact. Second, it immediately points out any harmful changes: the tests will break. (This is why it's possible to refactor mercilessly, if you have a good test suite.)
Programmer tests help you to be confident that the code you just wrote does what it should do (because it passes the tests you just wrote) and that the code you haven't touched still does what it should do (because it still passes its tests). Your new feature is complete when you can't think of any more tests to write and all the tests pass.
Customer Tests
Customer tests are slightly different from programmer tests. Instead of focusing on the implementation details at an API level, they explore the behavior of the program from the customer's point of view.
XP recommends that a developer help the customer write appropriate tests for each requested feature. As with programmer tests, when the customer tests all pass for a feature (and the existing customer tests still pass), the feature is complete.
Customer tests give you similar confidence that you haven't broken customer-visible behavior. They also give you a simple but effective way to track your progress. If the customer has asked for five features and the tests for three pass, you're 60 percent complete. Other XP techniques exist for making estimates, but relying on test successes is fairly accurate.
Communicate Early and Often
If you're truly ready to adapt to change, you need to know when it's coming. More importantly, you need to have a plan on how to adapt, whether you're a developer or the customer. You both have the same goal. You both need to let each other know when something changes.
XP recommends adding the customer to your development team. You'll work and plan together, in the same room. It's really easy to ask the customer any question that comes to mind. It's faster and easier to get a sense of his or her real needs and it's faster and easier for him or her to see how you're really doing.
Find Out What You Need to Do
The software exists to meet the customer's needs. If his needs change, you need to know to adjust your development and the software. The best way to do this is to talk directly to the customer. Capture this knowledge in customer tests, and you'll always have it at your fingertips. Run these tests often to measure your progress.
Make Your Progress Obvious
Of course, the customer's not the only one who might see changes. A feature might take longer to implement than you anticipated. It may take much less time. Whatever the case, your progress may affect the customer's decisions. If you discover that it will take six months to deliver the features the customer has requested in three months, you need to reconcile your schedules somehow.
Having a good test suite and running it often will give you a good progress report. Let the customer know where you are and what you are doing. This will help him or her decide what to do next.
Do Things That Matter
One of the biggest controversies in XP is its focus on doing only things that help you solve the customer's problem. This translates into not writing much in the way of specifications or documentation unless it's actually necessary. It also means not doing much in the way of up-front design before you know what you actually need to code.
It's easy to take this too far, never planning ahead and only ever coding. That's a mistake, though. If you need to write documentation, do it. If you need a written specification, write it. If you need to plan ahead for a tricky part of your software, break out the whiteboard, CRC cards, and draw some UML—but only if you need them.
When Coding
When you're writing code, spend your time on things that will pay off. Instead of writing code, compiling it if possible, then running a few tests by hand, turn the tests into executable code that will stay with the system. Instead of writing a general framework to solve a problem, solve the problem first. Wait until you really need the framework to pull it out.
This is very similar to the "Do the Simplest Thing That Could Possibly Work" rule. If you're running the tests and checking the output by hand, spend the time necessary to automate your tests. Know what's important and either automate away or discard everything else.
When Developing
The same rule applies to your entire development process. If your weekly four-hour meetings aren't useful, get rid of them. Many XP teams get by with a daily, ten-minute "stand-up" meeting, similar to Scrum's Daily Scrum. If tracking your estimates and your passing tests gives you enough metrics, don't worry about lines of code or defect rates.
If you really do need something (monthly milestones, for example), use them without apology. Think about what you're doing and why you're doing it. It's OK to stop doing things that aren't helping.
Fix Your Most Important Problem First
Perhaps the most important rule in XP is never expressed directly. Find what's not working on your project. You'll probably have to trace several symptoms back to the source. Once you know what the real cause is, figure out how to solve the problem. Then solve it.
Perhaps you're working with several customers who are often frustrated and surprised to see what's actually delivered several months after they request it. "This isn't what I wanted," they say, while you point to the contract. In this case, your real problem isn't that the customers have changed their minds. It's that they haven't been involved in the processes to see what's being done and to make suggestions.
Perhaps your delivery dates keep slipping. Instead of working longer hours, and cutting out code reviews and testing because "they just slow us down," your schedule may be too ambitious and the code you're producing may need too much debugging. Perhaps cutting back on the amount of work you've promised and doing more testing and more reviews will help you meet your deadline better.
Whatever the case, your project likely has at least one area for improvement. Find the real problem and fix it. Then move on to the next most important area for improvement.
Final Thoughts
While XP has a devoted following, it doesn't apply everywhere.
XP has traditionally worked best in small or medium-size teams composed of competent developers who work well together; where the customer's requirements may change frequently; and where frequent, small releases are possible. That excludes a few projects. While it's possible to adapt XP to different environments, it may take more time than you have right now. That's OK. There's still plenty to learn from XP in the meantime.
If you have an existing development process that's working well for you, stick with it. There may be ideas to borrow from XP, Scrum, CMM, or RUP that make your life easier. Do so! Whether XP is a flavor of the month or it sticks around for decades, there are plenty of people writing about it and even more adopting it. Take advantage of this to explore which XP practices, ideas, and goals will work for your team.
chromatic promotes free and open source software for O'Reilly's Open Technology Exchange.
![]() |
Essential Reading How to Keep Your Boss from Sinking Your Project Like it or not, your project needs management. Yet few good software projects can survive bad management. If you're a programmer on a high-visibility project, this PDF offers five principle guidelines for managing upward that will help you help your boss make the right decisions about setting project expectations, working with users and stakeholders, putting the project on the right track and keeping it there. The PDF also covers what problems cause projects to fail and how to fix them, and what you can do to keep your software project from running into trouble. Read Online--Safari Search this book on Safari: |
O'Reilly & Associates recently released (July 2003) Extreme Programming Pocket Guide.
Sample Excerpt, Roles in Extreme Programming, is available free online.
You can also look at the Table of Contents, the Index, and the Full Description of the book.
For more information, or to order the book, click here.
Return to ONLamp.com.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 18 of 18.
-
Absolutely knowledge gaining...
2003-09-03 01:52:25 anonymous2 [Reply | View]
I think that this particular article solves alot of fuzzy know-how on the topic of Extreme programming that a newbie might have...
Ronsley Vaz
School of Computing and Information Technology
Griffith University
-
Well done!
2003-08-21 07:32:12 ronjeffries [Reply | View]
Good article, chromatic. The little book looks good too, and with a great foreword from Ward as well. I'll be posting a review on XProgramming soon.
Thanks!
-
eXPosing the Incompetent?
2003-08-17 13:42:53 anonymous2 [Reply | View]
I worked on various medium-sized programming projects for 25 years, teams of 5-20 with some people leaving and others joining rather frequently. Our customers were in-house. Generally the programs had complex algorithms, were old and constantly in need of maintenance and major extensions. These 5 lessons are a good summary of what worked when things worked.
However, when I consider XP as a whole, the one thing that would have made the biggest difference--by factors of 10--to success on the projects I worked and others I am familiar with would have been the eXPosure, through pair programming or code reviews, of the amazingly inept persons who were often the ones who stayed around the longest.
-
XP is so right, but...
2003-08-15 04:56:46 anonymous2 [Reply | View]
You need mature customers. If you ask a customer who has never seen a software for this problem domain, he will change his mind EVERY time you ask him the same question.
Mature customers are sure about what they want because they have already worked in the field for many years and they know it is not their job to make late suggestions, they are not being paid for asking for a "last one thing", that that we really need. Immature customers are never satisfied with the software unless you accept those late requirements as top priority. The problem with those late requirements is that they are always top priority, so new requirements will always leave older requirements unsolved. Over a long period fo time you will not have finished anything.
XP solves that through frozen releases. Whatever was top priority and accepted to be done in this release will be released in this time frame, it does not matter if priorities change. If something was misunderstood as each user story can't now be implemented in the time frame, they are simply tossed from the release. But beware that you may end up delivering absolutely nothing if the customer is immature enough.
-
True......but it always was
2003-08-12 04:33:27 anonymous2 [Reply | View]
This five point summary is an excellent list of goals to bear in mind when creating good software. But every item applies to every properly conducted software project, whatever methodology it claims to use.
The most important thing that XP has done is to make it cool again to deliberately write maintainable, robust code. It’s an attitude of mind that has little or nothing to do with following any particular development process.
Still, it’s good to see movement against the quick and dirty “slopware” that badly damaged the reputation of US-developed products.
-
XP is individual-oriented programming
2003-08-10 04:35:25 mkj6 [Reply | View]
To setup an XP team you must work not only with very skilled but open-minded people: pair programming can be a problem if you don't feel comfortable with your desk-mates. Many XP evangelists suggest what seems a religious approach to test-driven programming, but tests are code, and someone have to maintain it! Moreover, testing is most useful in algorithmic-oriented pieces of code. What I find to be indispensable is evolutionary design by refactoring, always trying to apply the DRY principle (Don't Repeat Yourself). Then I write tests for the most critical sections, this way I feel confident while I'm changing. XP still requires a lot of craftsmanship and expertise, but it often works better than many other methodologies.
-
Development with XP, but without a team
2003-08-08 23:25:13 anonymous2 [Reply | View]
Hi, this article contains the most important rules from XP and is nice to read.
My problem with XP is to begin a new project based on open source and without a concretely team.
This can occur when i start my ideas to implement, but i haven't a possible partner to pair with him.
I try to obtain some programers as soon as possible.
But what's with the time i waste until i found some interested people.
But my greatest problem is to develop an open source project, without a concretely customer, who write automated tests.
I look forward to some responses! -
Development with XP, but without a team
2003-08-09 23:40:50 chromatic |
[Reply | View]
When I first learned about XP, I was working as a system administrator and contributing to open source projects in my spare time. Those are the same questions I had.
I'm putting together a followup article entitled "Five Things Open Source Developers Should Learn from Extreme Programming" that will go into more detail. It should be ready in about three weeks.
For now, my best advice is to wear two hats. One hat is for the customer. Look at things from a user's point of view. The other hat is the normal developer hat.
It can be tricky to combine these responsibilities, but if you have the discipline to follow the other XP practices, you'll be able to do this one.
Thanks for the comments!
-
XP or What ?
2003-08-07 07:40:02 anonymous2 [Reply | View]
Mr. o'Reilly, congratulations, I´m one old programmer, I believe that I know something about of programing, but I always have problems with Operating System and Languaje of programing. Now I´m finishing one Magister in networks and all my friends of studys have same problems. We believes that with YOUR peer to peer technology, meme maps, setty, etc. Do it something. Excume my English. We are from Barquisimeto Venezuela. Bye... -
XP or What ?
2003-08-08 15:59:29 anonymous2 [Reply | View]
Jejejeje
<spanish>
Si, tu ingles esta un poco piche, pero bueno, practica y mejoralo ;)
Saludos de un venezolano en Stamford, CT.
</spanish>
It is a good article. Now i'm wondering how to apply the techniques described above.
JV. -
Where to Start
2003-08-08 16:48:47 chromatic |
[Reply | View]
Thanks for the comments.
In the book, I recommend building a healthy team as the first step. If you already have this, great! It's a lot easier to sit down and figure out what your biggest problem is.
If you can't really do that as a team, at least you've identified your biggest problem.
That's where I'd start. Chances are, everyone can identify something that you could do better. Trace those back to the source and you have a starting point.
-
Finally a Sane article on XP.
2003-08-06 04:36:29 anonymous2 [Reply | View]
Thanks , for the nice, concise and sensible article on XP. While we do practice some processes (Unit Testing, Weekly builds) which are now tenets of XP I refuse to identify myself as an XP'er. Most of the articles you read on XP sound like they are marketing some miracle diet or a new wonder drug. This article provides a nice balanced view without geting into the *preach* mode. -
Finally a Sane article on XP.
2003-08-15 05:14:00 anonymous2 [Reply | View]
You do unit tests, that's good.
You do weekly builds, that's not so good.
XP is about building the software several times a day using automated software like CruiseControl. If you build only once a week, it means you are checking-in only once a week, and problems found after the build are solved during the whole next week.
It is not agile to do things like that, you need to check-in daily, even if you just changed a method, if it passes all the tests, check it in. CruiseControl will verify that your check-in is safe a few minutes after you checked-in that code.
Solving build breaks is the responsability of the committer. Usually build breaks are published on a web site, which means every developer has a reputation at risk, and they are TOLD that build breaks are priority 1, so they solve build breaks (or test breaks) a few minutes after they are produced. IMHO, that's the basis of being agile.
-
A problem that we have
2003-08-05 23:48:20 anonymous2 [Reply | View]
With such frequent releases, it is essential to automate the customer tests, but it is also extremely difficult to do that, esp. when your product involves web interfaces, web services, file outputs and other interfaces (LDAP, RADIUS etc.)
b) -
A problem that we have
2003-08-07 08:07:08 anonymous2 [Reply | View]
There are some excellent open-source tools now that help with automating customer/integration tests.
Check out HttpUnit and Cactus. These tools aren't perfect for everything, but they are remarkably powerful, flexible, and a huge improvement on "screen scraper" commercial testing products.









Ontologist