Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

XP distilled

How to achieve greater success on your Java projects

Roy Miller (miller@rolemodelsoft.com), Software Developer, RoleModel Software, Inc
Roy W. Miller is a Software Developer at RoleModel Software, Inc. While at RoleModel, Roy has developed a Java/XML-based automated acceptance testing framework and has prototyped several applications for the TINI Java platform from Dallas Semiconductor. Prior to joining RoleModel, he spent six years with Andersen Consulting (now Accenture) using their proprietary heavyweight Business Integration Methodology (BIM) and variations thereof. Since joining RoleModel, he has gained experience with XP and local adaptations of that approach. Roy has co-authored a book in the Addison-Wesley XP Series (XP Applied, scheduled for publication in October 2001), and will be a featured panelist at the XP2001 "Business of XP" fishbowl. Contact Roy at rmiller@rolemodelsoft.com.
Christopher Collins (ccollins@rolemodelsoft.com), Senior Software Developer, RoleModel Software, Inc
Christopher T. Collins is a Senior Software Developer at RoleModel Software, Inc. While at RoleModel, Chris has taken part in an XP project that has run for almost two years, developed an embedded Java application for a new Motorola cell phone platform, and ported JUnit to run on Sun's J2ME platform. Before joining RoleModel, he spent five years developing software for several organizations using many different languages, most recently for U.S. Department of Defense applications. He has experience using and adapting several different development methodologies, both agile and heavyweight, including RUP and XP. Chris has an M.S. in Computer Science and Software Engineering from the University of West Florida, and currently teaches a Java programming course at North Carolina State University. He has been an invited speaker on XP at Duke University, and will be presenting a paper on process adaptation at XP2001. Contact Chris at ccollins@rolemodelsoft.com.

Summary:  Object-oriented programming using the Java language has become immensely popular. It has revolutionized software development to some degree, but recent studies show that half of software development projects are late, and one-third are over budget. The problem isn't the technology; it's the way we develop software. So-called "lightweight" or "agile" approaches, coupled with the power and flexibility of object-oriented languages like the Java language, offer an intriguing solution. The most popular agile approach is called Extreme Programming, or XP, but many people don't really know what it is. Using XP on your Java projects can increase your chances of success dramatically. This article provides an overview of XP and explains why it is important -- without the rumor or the hype.

Date:  01 Mar 2001
Level:  Introductory
Also available in:   Japanese

Activity:  12881 views
Comments:  

CEOs have faced enormous pressure over the last decade to produce steadily rising earnings. We have seen their response in such initiatives as corporate downsizing, outsourcing, re engineering, enterprise resource planning (ERP), and others. This attack on inefficiency has allowed many of the organizations in the S&P 500 to maintain double-digit earnings growth for several years during the latter part of the 1990s. But something wicked this way comes.

In his book Leading the Revolution (see Resources), Gary Hamel asserts that several indicators demonstrate that not much fat is left to cut in traditional business models. We must find alternatives for fueling continued earnings growth. He suggests the only thing that will allow companies to continue generating growth is radical innovation. We think this is especially true in the area of software development.

The business problem

If you use standard software development approaches, even if you are developing on the Java platform, prepare yourself for disappointment. As Figure 1 shows, recent studies indicate that you can expect half of your projects to be late and one third of them to be over budget. This projection is only slightly better than the study done in 1979 by the Government Accounting Office.


Figure 1. Software project success and failure, then and now
Software project success and failure statistics

If we are to improve these numbers significantly, we need radically innovative ways to develop software. Two primary factors influenced existing methodologies:

  • Fear of failure
  • A misunderstanding of the nature of software

Nobody plans to fail. The irony is that approaches created to minimize failure are failing. Misunderstanding software is the root of the problem. Fear really is just a symptom. Existing methodologies were created by smart people who meant well but who forgot the "soft" in software. They assumed that making software is like building a bridge. So they borrowed best practices from various engineering disciplines that apply very well to "hard" things, like bridges. The result is unresponsive development practices based on a Big Design Up-Front (BDUF) mentality, and brittle software that people can't use.


One solution: Agile methods

Recently, the movement has been away from so-called "heavyweight" methodologies to "lightweight" or "agile" ones such as Crystal Methods, Adaptive Software Development, and (currently the most popular) XP. All of these processes embrace the reality that people work with people to develop software. Successful software processes must maximize people's strengths and minimize their weaknesses, as both unarguably exist. In our opinion, XP does the best job of addressing all the complementary forces that affect the people involved.

XP represents the single biggest opportunity this decade to bring radical innovation to the process of software development. As Peopleware author Tom DeMarco puts it, "XP is the most important movement in our field today. I predict that it will be as essential to the present generation as the SEI and its Capability Maturity Model were to the last."

XP prescribes a core set of values and practices that allow software developers to do what they do best: write code. XP eliminates the unnecessary artifacts of most heavyweight processes that distract from that goal by slowing down and draining the development staff (for example, Gantt charts, status reports, and multi-volume requirements documents). We recognize that something called "Extreme Programming" might be tough to sell to your management as a serious development process, but if your company is in the software business, it behooves you to help management see past the name to the competitive advantage XP can provide.

Kent Beck outlined the core values of XP in his book Extreme Programming Explained: Embrace Change (see Resources). We summarize them this way:

  • Communication. Problems with projects often can be traced back to somebody not talking to somebody else about something important at some point. XP makes it almost impossible not to communicate.

  • Simplicity. XP proposes that you always do the simplest thing that could possibly work with regard to process and writing code. The way Beck puts it, "XP is making a bet. It is betting that it is better to do a simple thing today...than to do a more complicated thing today that may never be used anyway."

  • Feedback. Concrete feedback early and often from the customer, from the team, and from real end users gives you more opportunity to steer your efforts. Feedback keeps you on the road and out of the ditch.

  • Courage. Courage exists within the context of the other three values. They all support each other. It takes courage to trust that concrete feedback along the way is better than trying to know everything up front. It takes courage to talk to others on the team when that might expose some of your own ignorance. It takes courage to keep the system simple, deferring tomorrow's decisions until tomorrow. And without a simple system, constant communication to spread knowledge, and feedback to steer with, it's tough to be brave.

The practices of XP translate these values into the things you should do every day as a developer. There isn't much new here. The XP practices have been recognized by the industry for years as "best practices." In fact, the word "extreme" in XP derives from two things:

  • XP takes proven industry best practices and turns the knobs up to 10.
  • XP combines those practices in a way that produces something greater than the sum of the parts.

What does this look like? Code reviews are good, so do them all the time by writing code in pairs. Testing is good, so do it all the time by writing tests before you write code. Documentation rarely stays in sync with the code, so do only the minimum necessary and depend on clearly written code and tests for the rest. XP doesn't guarantee that people will do the right thing all the time, but it allows them to. It combines these "extreme" practices in a mutually supportive way that produces significant increases in speed and efficiency.


Twelve practices of XP

The twelve practices of XP (shown in Figure 2) define it as a discipline. Let's take a closer look at each to get a better understanding of what it means to "do XP."


Figure 2. Twelve practices of XP
12 practices of XP

The planning game

Some people like to criticize XP as glorified hacking, just a bunch of cowboys cobbling together a system without any discipline. Wrong. XP is one of the few methodologies out there that recognizes that you can't know everything when you start. Both the customers and the developers will learn things as the project progresses. Only methodologies that encourage and embrace such change will be effective. Status quo methodologies ignore change. XP listens. The way it listens is through the "planning game," a concept coined by Kent Beck.

The main idea behind this practice is to make a rough plan quickly and refine it as things become clearer. The artifacts of the planning game are: a stack of index cards, each containing a customer story, which will drive the project's iterations; and a rough plan for the next release or two, as described in Planning Extreme Programming (see Resources) by Kent Beck and Martin Fowler. The critical factor that lets this style of planning work is letting the customer make business decisions and allowing the development team to make technical ones. Without that, the whole process falls apart.

The development team determines:

  • Estimates of how long it will take to develop a story
  • Cost implications of using various technology options
  • Team organization
  • The "risk" of each story
  • Order of story development within an iteration (doing risky items first can mitigate risk)

The customer determines:

  • Scope (the stories for a release and the stories for each iteration)
  • Release dates
  • Priority (which features get developed first, based on business value)

Planning happens often. This provides frequent opportunity for either the customer or the developers to adjust the plan as they learn new things.

Pair programming

In XP, pairs of developers write all production code. This approach may sound inefficient. As Martin Fowler says, "When people say that pair programming reduces productivity, I answer, 'that would be true if the most time-consuming part of programming was typing.'" In fact, pair programming provides many benefits, economic and otherwise:

  • All design decisions involve at least two brains.
  • At least two people are familiar with every part of the system.
  • There is less chance of both people neglecting tests or other tasks.
  • Changing pairs spreads knowledge throughout the team.
  • Code is always being reviewed by at least one person.

Research also is showing that programming in pairs is actually more efficient than programming alone (see The Costs and Benefits of Pair Programming by Alistair Cockburn and Laurie Williams in Resources for more details).

Testing

There are two kinds of testing in XP:

  1. Unit testing
  2. Acceptance testing

Developers write the unit tests as they write code. The customer writes acceptance tests after they define stories. Unit tests tell developers whether the system "works" at any point in time. Acceptance tests tell the team whether the system does what users want it to do.

Assuming the team is using an object-oriented language like Java, developers write unit tests for every method that could possibly break, before they write the code for those methods. Then they write just enough code to get the test to pass. People sometimes find this a little weird. The point is simple. Writing tests first gives you:

  • The most complete set of tests possible
  • The simplest code that could possibly work
  • A clear vision of the intent of the code

A developer cannot check code into the source code repository until all the unit tests pass. Unit tests give developers confidence that their code works. It leaves a trail for other developers to understand the original developer's intent (in fact, it's the best documentation we've ever seen). Unit tests also give developers courage to refactor the code, because a test failure tells the developer immediately if something's broken. Unit tests should be automated and give a clear pass/fail result. xUnit frameworks (see Resources) do all this and more, so most XP teams use them.

Customers are responsible for making sure each story has acceptance tests to validate it. The customer can write the tests himself, recruit other members of his organization (for example, QA people or business analysts) to write them, or combine the two approaches. The tests tell them if the system has the features it is supposed to have, and that they work correctly. Ideally, the customer will have the acceptance tests for the stories in an iteration written before that iteration is finished. Acceptance tests should be automated and run frequently to ensure developers are not breaking any existing features as they implement new ones. Typically, customers will need some help from the development team to write acceptance tests. On one project, we developed a reusable automated acceptance test framework that lets the customer enter inputs and expected outputs in a simple editor. The framework converts the input to an XML file, runs the tests in the file, and spits out "pass" or "fail" for each. Customers love it.

Not all of the acceptance tests have to pass all the time. The point is that acceptance tests help customers gauge how "done" the project is. They also allow customers to make informed decisions about whether or not something is ready for release.

Refactoring

Refactoring is the technique of improving code without changing functionality. An XP team refactors mercilessly.

Two key opportunities exist for developers to refactor: before and after implementing a feature. Developers try to determine if changing existing code would make implementing the new feature easier. They look at the code they just wrote to see if there is any way to simplify it. For example, if they see an opportunity for abstraction, they refactor to remove duplicate code from concrete implementations.

XP says you should write the simplest code that could possibly work, but it also says you'll learn along the way. Refactoring lets you incorporate that learning into your code without breaking the tests. It keeps your code clean. That means it will survive longer, introduce fewer problems for future developers, and guide them in the right direction.

Simple design

XP's detractors claim that the process neglects design. This isn't true. The problem is that heavyweight approaches say you should do all but the most trivial design tasks up front. This is like taking a static picture of the horizon, staying still, and trying to draw a perfect map of how to get there. XP says design should not be done all at once, up front, under a delusion that things won't change. XP considers design so important that it should be a constant affair. We always try to use the simplest design that could possibly work at any point, changing it as we go to reflect emerging reality.

What is the simplest design that could possibly work? It is the design that (thanks to Kent Beck for this list):

  • Runs all the tests
  • Contains no duplicate code
  • States the programmers' intent for all code clearly
  • Contains the fewest possible classes and methods

Requiring a simple design doesn't imply that all designs will be small or that they will be trivial. They just have to be as simple as possible and still work. Don't include extra features that aren't being used. We call such things YAGNI, which stands for "You Aren't Going to Need It." Don't let YAGNI destroy your chances for success.

Collective code ownership
Any person on the team should have the authority to make changes to the code to improve it. Everybody owns all the code, meaning everybody is responsible for it. This technique allows people to make necessary changes to a piece of code without going through the bottleneck of an individual code owner. The fact that everybody is responsible negates the chaos that ensues from no code ownership.

Saying that everybody owns all the code isn't the same as saying that nobody owns it. When nobody owns code, people can wreak havoc anywhere they want and bear no responsibility. XP says, "You break it, you fix it." We have unit tests that must run before and after each integration. If you break something, it's your responsibility to fix it, no matter where it is in the code. This requires extreme discipline. Maybe that's another reason for having "extreme" in the name.

Continuous integration

Frequent code integration helps you to avoid integration nightmares. XP teams integrate their code several times a day, after they get all the unit tests for the system to run.

Traditional approaches tend to work like this: code a lot, do a big-bang integration, then spend a significant amount of time fixing the problems. This yo-yo style really slows a project down. Big-bang integrations dump a load of problems on the team all at once, and those problems often have hundreds of possible causes.

When you integrate frequently, the cause of failure for any particular integration is more obvious (the tests ran before, so the new stuff must be to blame). This way, when you encounter problems, there is a rather limited set of possible causes. Fixing is easier, takes less time, and keeps the team moving at maximum speed.

On-site customer

To function optimally, an XP team needs to have a customer available on site to clarify stories and to make critical business decisions. Developers aren't allowed to do that alone. Having a customer available eliminates bottlenecks that can arise when developers have to wait for decisions.

XP does not pretend that a story card is all the direction a developer needs to deliver the necessary code. The story is a commitment to a later conversation between the customer and the developer to flesh out the details. The idea is that communicating face to face minimizes the chances of misunderstanding, unlike writing all the requirements down in a static document.

We have found that having the customer on site is the best possible situation, but it's not the only scenario that will work. The bottom line is that the customer must be available whenever needed to answer questions and to provide direction for the team based on business value. If that can happen without the customer being on site with the team full-time, great. Physical presence with the team makes this much easier, however, thus the recommendation.

Small releases

Releases should be as small as possible while still delivering enough business value to make them worthwhile.

Release the system as soon as it makes sense to do so. This provides value to the customer as early as possible (remember that money today is worth more than money tomorrow). Small releases also will provide concrete feedback to developers on what meets customer needs and what doesn't. The team then can include these lessons in its planning for the next release.

40-hour week

Kent Beck says that he wants to be "...fresh and eager every morning, and tired and satisfied every night." The 40-hour work week lets you do that. The exact number of hours isn't important - the principle is. Burning the oil for long periods kills performance. Tired developers make more mistakes, which will slow you down more in the long run than keeping a "normal" schedule will.

Even if developers could function well for longer periods, it doesn't mean they should. Eventually, they'll get tired of it and leave their jobs, or have non-work problems that will impact their performance. You mess with people's lives, you suffer the consequences. Overtime isn't the answer to a project's problem. In fact, it's a symptom of a larger problem. If you need a death march, you screwed up.

Coding standard

Having a coding standard does two things:

  • It keeps the team from being distracted by stupid arguments about things that don't matter as much as going at maximum speed.

  • It supports the other practices.

Without coding standards, it is harder to refactor code, harder to switch pairs as often as you should, and harder to go fast. The goal should be that no one on the team can recognize who wrote which piece of code. Agree on a standard as a team, then stick to it. The goal isn't to have an exhaustive list of rules, but to provide guidelines that will make sure your code communicates clearly. Your coding standard should begin simply, then evolve over time based on team experience. Don't spend too much time on it up front. Create the simplest standard that could possibly work, then get moving.

System metaphor

What does an architecture do? It provides a picture of the various components of a system and how they interact -- a sort of map that lets developers see where new pieces will fit.

The system metaphor in XP is analogous to what most methodologies call architecture. The metaphor gives the team a consistent picture they can use to describe the way the existing system works, where new parts fit, and what form they should take.

It is important to remember that having everyone understand how the system fits together is critical, not a beautiful metaphor. Sometimes, you just can't come up with a good one. It's great when you can.


The practices work together

The whole is greater than the sum of the parts. You can implement single practices, or a small subset, and get great benefits over not using any. But you only get the maximum benefit if you implement all of them, because their power comes from their interaction.

Do XP by the book at first as a benchmark. Once you understand how the practices interact, you will have the knowledge you need to adapt them to your context. Remember that "doing XP" is not the goal, it is a means to an end. The goal is developing superior software quickly. If your process mutates in a manner that disqualifies you from saying you are doing XP, yet your results are blowing the doors off your competitors, you have succeeded.


Why XP matters

To be blunt, XP (or any other agile methodology) doesn't matter at all. The results it can produce are what count. If an agile approach like XP can help you deliver better software faster and without as much pain, then it is worth considering.

Remember those daunting numbers we mentioned at the start of this article? We believe that using XP to develop object-oriented software has the best chance of changing them for the better. Our experience so far has confirmed that belief.


Resources

About the authors

Roy W. Miller is a Software Developer at RoleModel Software, Inc. While at RoleModel, Roy has developed a Java/XML-based automated acceptance testing framework and has prototyped several applications for the TINI Java platform from Dallas Semiconductor. Prior to joining RoleModel, he spent six years with Andersen Consulting (now Accenture) using their proprietary heavyweight Business Integration Methodology (BIM) and variations thereof. Since joining RoleModel, he has gained experience with XP and local adaptations of that approach. Roy has co-authored a book in the Addison-Wesley XP Series (XP Applied, scheduled for publication in October 2001), and will be a featured panelist at the XP2001 "Business of XP" fishbowl. Contact Roy at rmiller@rolemodelsoft.com.

Christopher T. Collins is a Senior Software Developer at RoleModel Software, Inc. While at RoleModel, Chris has taken part in an XP project that has run for almost two years, developed an embedded Java application for a new Motorola cell phone platform, and ported JUnit to run on Sun's J2ME platform. Before joining RoleModel, he spent five years developing software for several organizations using many different languages, most recently for U.S. Department of Defense applications. He has experience using and adapting several different development methodologies, both agile and heavyweight, including RUP and XP. Chris has an M.S. in Computer Science and Software Engineering from the University of West Florida, and currently teaches a Java programming course at North Carolina State University. He has been an invited speaker on XP at Duke University, and will be presenting a paper on process adaptation at XP2001. Contact Chris at ccollins@rolemodelsoft.com.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=10522
ArticleTitle= XP distilled
publish-date=03012001
author1-email=miller@rolemodelsoft.com
author1-email-cc=
author2-email=ccollins@rolemodelsoft.com
author2-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers