Ken Orr wrote ( in Cutter IT Journal Vol.3, No. 7 ):

Agile . since Jun 23 . Index . DOCs TOP TOC

Testing


"Top XP teams practice 'test-driven development,' working in very short cycles of adding a test, then making it work. Almost effortlessly, teams produce code with nearly 100% test coverage, which is a great step forward in most shops," writes Beck [1].

Test-driven development means that agile development starts by defining tests before developing code. It is easy to overlook the importance of this idea. In doing so, programmers are forced to work out the inputs and outputs that they are trying to achieve and then to build code that produces the correct results from the predefined tests. Like so many factors in agile development, the basic strategy rather than a set of heavy-handed management controls is responsible for good code and good programming discipline.

Agile . since Jun 23 . Index . DOCs TOP TOC

Refactoring


Refactoring is one of the most interesting ideas of agile development. In essence, refactoring involves the constant redesign of the entire OO class hierarchy, and methods such as new requirements come to be known. Agile development programs evolve through iteration. At each release, new requirements are introduced. Each new set of requirements mandates that the programming team go back and design these new requirements into the existing code.

Refactoring goes hand in hand with the idea of minimal requirements. One of the basic tenets of XP, and therefore, agile development, is that of implementing only those requirements that are known for certain and that are involved in the current release.

Historically, one of the problems with radical iterative design is that after a number of iterations, the program(s) becomes increasingly difficult to maintain. As change after change is added to the program, it becomes more and more difficult to understand. However, with the idea of refactoring, the design is revisited at each iteration, and changes are integrated, thus making the systems evolution smoother.

In my opinion, refactoring is one of the key ideas of agile development. If agile development's form of iterative development with minimal documentation is to succeed, then there must be an increased emphasis on design. Refactoring really means design/redesign.

Early versions of OO design emphasized spending enormous amounts of time designing class hierarchies and methods before building an application using the classes and methods. But this made early OO very front-end loaded. A great deal of time was usually spent on the initial classes, only to discover that you always had to redo them as the project progressed and you learned more about the problem. In OO, this became known as "class thrashing."

In agile development, there is minimal design up front, but that minimal design is repeated for each iteration. The belief is that if you do it right, the program will improve, not degrade over time. There are some difficulties with this approach, however. For one, manually refactoring OO code is not an easy task, and, for another, some kinds of refactoring (i.e., data refactoring) are much more difficult than others.

Unfortunately, even though agile development, coming as it does from OO, is a highly technical approach, there is little discussion about the importance of automated tools in such critical areas as class and method refactoring. Because of the property of inheritance, changes in one class often ripple through a system in unpredictable ways. Recently, tools have begun to make this process faster and more reliable.13

Class and method refactoring are only one part of the problem. An equally large problem that has been largely ignored by agile development is the importance of data refactoring. Most of the major problems associated with redesign occur whenever it is necessary, for whatever reason, to redesign the underlying database. Historically, OO design has been somewhat light on database design and redesign. In the analysis section of this report beginning on page 14, we will discuss both the importance of data refactoring and automated refactoring tools, of which automated database redesign tools are the most important.

Agile . Index . DOCs . TOC