Chapter 5. Coding Practices

Writing code is the most important practice in software development—very few projects can succeed without writing code.[3] Most of the time and energy devoted to a project are concentrated on producing code. Consequently, XP is very much concerned with code.

The code is the most important artifact of the project—without it, the project does nothing. It is the final authority on how the system actually behaves. As a developer, code is your business. This focus worries many people, who fear that XP is the domain of cowboy coders who jump headfirst into hacking without planning. This is not the case. XP uses working code to validate and to evaluate its plans. The four coding practices work together to produce code that is easy to maintain and extend and is always ready to be delivered to the customer.

Coding Practice 1: Code and Design Simply

Goal: to produce software that’s easy to change.

Code and design simply. Solve the customer’s current need. Resist the urge to guess at future needs, whether you’re designing the next feature or coding it. XP has three rules that govern simplicity: Do the Simplest Thing That Could Possibly Work, You Aren’t Gonna Need It, and Once and Only Once (these are explained in Part VI).

Flexibility is the goal. Simplicity is the means to that end. Simple designs are easier to understand and to explain. Simple code is easier to test, maintain, and change.

XP spends comparatively little time creating designs before writing code, preferring ...

Get Extreme Programming Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.