O'Reilly logo

Extreme Programming Pocket Guide by Chromatic

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Developer Practices

On all but the smallest projects, developers must work together. The more smoothly you can do this, the greater your chance of success. Everyone contributes to the project, so XP devotes several practices to improving teamwork. These practices reinforce good programming habits by guiding less experienced developers and keeping everyone on track.

Developer Practice 1: Adopt Test-Driven Development

Goal: to prove that the code works as it should.

Adopt test-driven development. Write a test that fails. Write code to pass the test. Check that the test passes. Refactor the code. Automate your tests. Keep them passing. Use failing tests to prompt you to write code. This cycle produces a natural rhythm of rapid feedback.

Traditional testing is difficult, especially when you’re testing your own code. There is tremendous pressure for success. Writing a test that fails can be disheartening. It’s easy to rush through tests after you’re “done,” expecting that everything works correctly. Test-driven development is different. Tests are supposed to fail; there’s no code yet to make them pass! Writing the code to pass the test will give you a nice sense of accomplishment.

A feature is finished when all of its tests pass. Untested features do not exist. “Known issues” reduce that sense of immediacy, making debugging more difficult. Therefore, test failures should reflect only the last few minutes of changes to the system. Expected failures open the door for developers and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required