On one of the mailing lists I frequent, I commented that if people required discipline or management pressure to do documentation, perhaps that was a sign that it would be better to find a way of communicating that people found more natural. Asked in reply whether I thought the XP practices were natural in that sense, I said:
Yes. At least the practices are trying to go with the natural instincts of people (and of programmers). They try to set up behaviors which are self-sustaining, not through discipline or through pressure, but because they have results which are good and which are proximate enough to the behaviors so as to reinforce them.
In subsequent discussion, some folks wanted to hear a bit about how XP tries to "go with the flow". Here are some thoughts on the subject. We'll look at how XP ensures that you have the communication you need, without increasing the documentation you have to write.
It's a truism that programmers don't like to write documents. It's also a truism that on many projects the documents get out of date. It's conventional to blame the latter on the former, but the truth is that when the schedule gets tight, managers and project leaders are just as inclined to skip the updates as are programmers.
It's even possible -- this is just an idea, don't hold me to it -- that programmers don't like documentation because managers make it clear that what they really want is the program.
What do programmers like? They like to program. They like to write code; they like to make it work; they like to make it beautiful. How can we go with that natural instinct and meet our needs for documentation?
To begin with, let's look at why we want that documentation. For example, documents are used to communicate: to communicate requirements, internal design, status and information needed externally to the project. Let's look at those in turn. For each, we'll focus on what needs to be communicated and how XP helps make sure that the communication happens.
Some projects work from large requirements documents specifying what needs to be in the product. There are some issues with the use of such documents, and sometimes they are quite important:
Requirements documents may sometimes be necessary, but they are not without cost. XP tries a more natural way to communicate requirements: conversation.
In XP, there is the notion of the "On-Site Customer". Someone who knows what is needed -- ideally the actual customer or user -- is near the team at all times. They communicate the requirements directly, through several of the XP practices.
During the release planning process, the Customer explains all the requirements stories. There is discussion with the programmers until they understand the stories well enough to estimate them. This is communicating requirements.
During the iteration planning process, the Customer explains all the stories in more detail: enough detail for the programmers to figure out the detailed tasks to implement them. This is communicating requirements
The XP customer defines, and the team writes, acceptance tests for all the stories. These tests serve as executable requirements definitions. They can also be used quite readily as part of a tracking and documentation process showing that requirements have been implemented.
Because the Customer is On Site, she is also available for questions to clarify details of the requirements. She quickly learns to control how many interruptions she gets by improving the information she communicates during release and iteration planning. Too little, and she gets too many interruptions. Too much and she spends too much time in preparation. She can balance things between writing, conversation, and question answering to suit her own needs.
In summary, the On-Site Customer practice converts an inefficient paperwork exercise into a dynamic conversation discussing requirements as the project goes along. Everything is communicated -- must be communicated if the tests are to run -- and the balance between paper, presentation, conversation, and question answering can be adjusted to suit the participants.
All the members of the team need to understand the system. They need to be able to advance the code, to make it do whatever is needed. They need to do those changes in a way that are consistent with the overall shape of the code, and the direction it is moving: we might say with its design.
One way to be sure that everyone on the team understands and follows the design is to create a design and document it with UML diagrams or words or both. Everyone would agree that you shouldn't do too much of this up front, but it's hard to say how much is too much.
To communicate a design in this way, you need good-looking documents. It's all very well if two of us design on a bar napkin with a ball-point pen, but if it has to communicate with the whole team, we really will need to produce something better-looking and more comprehensive. Thus we need a word processor and a diagramming tool, and the time to use them to build the documents we need, and to maintain them, don't we?
Well, no. Watch your programmers. They're always jabbering about design, drawing pictures on those bar napkins or on the whiteboard. They're always drawing circles and arrows and a few words beside each one. They're always communicating about design -- it's what they do. How can we use this natural communication to support the bulk of our need for in-team communication, reducing the need for formal documents?
The XP release planning process includes a step where the programmers take the stories and discuss them among themselves, in order to estimate them. To estimate them, they figure out roughly how to implement each story. Guess what: the programmers are communicating about design. And watch them carefully: sometimes when they think they might forget, they write a note about how to implement a story, right on the card! They're recording enough about the design to remember it later. This is design, and communication of design.
The XP Iteration planning process includes a step where the programmers brainstorm the tasks to do each story, putting the tasks on the whiteboard for later signup. This is a design step. The whole team is participating in the design, and seeing it take shape. The key design components are left on the whiteboard until implemented. This is design, and communication of design.
In XP Installed, I describe the Quick Design Session: a few programmers get together and do a little CRC session or draw some UML or discuss how to do something. When they come up with something interesting, they tell the folks who weren't in the session about it. They do this naturally: it's interesting and they want to talk about it. If they come up with an important notion, they'll draw and write it on the whiteboard and leave it up while it's useful. This is design, and communication of design.
XP teams practice pair programming. Pairs switch around daily, with everyone working with everyone. XP teams practice collective code ownership, so that everyone can (and does) work on all parts of the system from time to time. This is communication of design.
An essential aspect of XP is refactoring. Martin Fowler's book Refactoring is subtitled Improving the design of existing code. Refactoring is a process whereby the programmers (in pairs, of course) examine and consider whether the code is reflecting the design in their heads, and consider what the code is saying about what the design should be. Then they improve the code to improve the design. This is design, and communication of design.
Within the XP team, the practices bring about a high level of common understanding of the design. Using the natural willingness of programmers to talk about what they are doing and how cool it is, and using pair programming, XP teams spread what needs to be known without the need for much formality. Is there still a need for documentation within the team? Certainly there is, and each team and its management need to figure out what. But for internal purposes, there's not much.
Some aspects of your status certainly need to be communicated externally to the project team. These communications will often -- but not always -- lead to documents. In the next section, Communicating Externally, we'll look at how to get those materials. Here, let's consider the information, and how we can be sure folks know what they need to know. We've already mentioned all the conversation that goes on on an XP project. This does a lot to communicate status. Here are a couple of additional general techniques to start us off.
XP recommends a daily "standup" meeting, where the team stands in a circle and quickly raises issues that people need to understand. This will include design issues and the like, but the main thing is a quick review of status, requests for help, problems encountered, and discoveries made. The standup meeting makes sure that all the attendees know about everything that's going on. Naturally, customers and managers are invited, and should attend.
On one XP project I coached, the team manager wrote all the external status reports, and almost never had to go to team members for information, because he got everything he needed to know as part of the standup meeting.
Is there important status information that needs to be fresh in people's minds all the time? One good way to get that to happen is the Big Visible Chart. Here are some examples of useful charts:
These charts are just examples. Is there something your team needs to have in mind all the time? Make a Big Visible Chart: it could be all you need.
You may need external documentation to support the product, either at the design level or for user documentation. There's no magic here: just write a story asking for the document, schedule the story, and write the document. The natural flow of the process supports getting the work done. As far as I know, there's no "natural" way to get external documents written, but since the need for them varies by project, I'm comfortable saying that the customer just asks for (and therefore gets) whatever external documents are needed. Here are some quick hints.
The details of what to document and how to produce the information are always unique to the project and its people. But the focus that XP would recommend is always this:
Communicate using the hottest medium you possibly can: from face-to-face conversation at a whiteboard down through phone conversation, through email, video or audio tape, down to paper or its online equivalent.
Find ways to have people's everyday activities embody communication. Find ways to have their everyday activities automatically generate the information that needs to be published. Find ways to extract information from development artifacts like source code.
Treat periodic or specialized documents as stories: use your existing planning mechanisms to get them done.
Extreme Programming tries to make things happen in ways that people find natural and pleasant. In the case of documentation, this is accomplished by recognizing that the point is communication, not simply documentation, then using the most effective forms of communication, and the most automatic forms, wherever possible.
As always, questions and comments are welcome, and may often result in an update to this article or in a new one.
Scott Ambler: Essay on Communication.
Martin Fowler: What's a Model For?
Ron Jeffries: Documentation in XP.