Вы находитесь на странице: 1из 9

The Rules of Extreme Programming

Planning
User Stories User stories are written.
release plan Release planning creates the release schedule.
release often Make frequent small releases.
iterative The project is divided into iterations.
iteration planning Iteration planning starts each iteration.
Managing
optimize last Give the team a dedicated open work space.
steady pace Set a sustainable pace.
stand-up meeting A stand up meeting starts each day.
project velocity The Project Velocity is measured.
move people around Move people around.
fix xp Fix XP when it breaks.
Designing
simplicity Simplicity.
System Metaphor Choose a system metaphor.
CRC cards Use CRC cards for design sessions.
Spike solution Create spike solutions to reduce risk.
nothing early No functionality is added early.
refactor Refactor whenever and wherever possible.
Extreme Programming flow chart
Coding
customer on-site The customer is always available.
coding standard Code must be written to agreed standards.
Test Driven Development Code the unit test first.
pair programming All production code is pair programmed.
serial integration Only one pair integrates code at a time.
continuous integration Integrate often.
continuous integration Set up a dedicated integration computer.
collective ownershipUse collective ownership.
Testing
unit tests All code must have unit tests.
unit tests All code must pass all unit tests before it can
be released.
tests When a bug is found tests are created.
acceptance tests Acceptance tests are run often and the score
is published.
http://www.extremeprogramming.org/rules.html

Refactor Mercilessly
We computer programmers hold onto our software designs long after they have beco
me unwieldy. We continue to use and reuse code that is no longer maintainable be
cause it still works in some way and we are afraid to modify it. But is it reall
y cost effective to do so? Extreme Programming (XP) takes the stance that it is
not. When we remove redundancy, eliminate unused functionality, and rejuvenate o
bsolete designs we are refactoring. Refactoring throughout the entire project li
fe cycle saves time and increases quality.
Refactor mercilessly to keep the design simple as you go and to avoid needless c
lutter and complexity. Keep your code clean and concise so it is easier to under
stand, modify, and extend. Make sure everything is expressed once and only once.
In the end it takes less time to produce a system that is well groomed.
There is a certain amount of Zen to refactoring. It is hard at first because you
must be able to let go of that perfect design you have
envisioned and accept the design that was serendipitously discovered for you by
refactoring. You must realize that the design you envisioned was a good guide po
st, but is now obsolete.
A caterpillar is perfectly designed to eat vast amounts of foliage but he can't
find a mate, he must refactor himself into a butterfly before he is designed to
search the sky for others of his own kind. Let go of your notions of what the sy
stem should or should not be and try to see the the new design as it emerges bef
ore you.
http://www.extremeprogramming.org/rules/refactor.html
Set a Sustainable, Measurable,
Predictable Pace
To set your pace you need to take your iteration ends seriously. You want the mo
st completed, tested, integrated, production ready software you can get each ite
ration. Incomplete or buggy software represents an unknown amount of future effo
rt, so you can't measure it. If it looks like you will not be able to get everyt
hing finished by iteration end have an iteration planning meeting and re-scope t
he iteration to maximize your project velocity. Even if there is only one day le
ft in the iteration it is better to get the entire team re-focused on a single c
ompleted task than many incomplete ones.
Working overtime sucks the spirit and motivation out of your team. When your tea
m becomes tired and demoralized they will get less work done, not more, no matte
r how many hours are worked. Becoming over worked today steals development progr
ess from the future. You can't make realistic plans when your team does more
work this month and less next month. Instead of pushing people to do more than h
umanly possible use a release planning meeting to change the project scope or ti
ming.
Fred Brooks made it clear that adding more people is also a bad idea when a proj
ect is already late. The contribution made by many new people is usually negativ
e. Instead ramp up your development team slowly well in advance, as soon as you
predict a release will be too late.
A sustainable pace helps you plan your releases and iterations and keeps you fro
m getting into a death march. Find your team's perfect velocity that will remain
consistent for the entire project. Every team is different. Demanding this team
increase velocity to match that team will actually lower their velocity long te
rm. So what ever your team's velocity is just accept it, guard it, and use it to
make realistic plans.
http://www.extremeprogramming.org/rules/overtime.html
Pair Programming

Lessons Learned
All code to be sent into production is created by two people working together at
a single computer. Pair programming increases software quality without impactin
g time to deliver. It is counter intuitive, but 2 people working at a single com
puter will add as much functionality as two working separately except that it wi
ll be much higher in quality. With increased quality comes big savings later in
the project.
The best way to pair program is to just sit side by side in front of the monitor
. Slide the key board and mouse back and forth. Both programmers concentrate on
the code being written.
Pair programming is a social skill that takes time to learn. You are striving fo
r a cooperative way to wok that includes give and take from both partners regard
less of corporate status. The best pair programmers know when to say "let's try
your idea first." Don't expect people to be good at it from the start. It helps
if you have someone on your team with experience to show everyone what it should
feel like.
One thing pair programming is not is mentoring. A teacher-stundent relationship
feels very different from two people working together as equals even if one has
significantly more experience. It takes time to get used to pair programming so
don't worry if it feels awkward at first. XP Rules
http://www.extremeprogramming.org/rules/pair.html
Integrate Often

Lessons Learned
Developers should be integrating and commiting code into the code repository eve
ry few hours, when ever possible. In any case never hold onto changes for more t
han a day. Continuous integration often avoids diverging or fragmented developme
nt efforts, where developers are not communicating with each other about what ca
n be re-used, or what could be shared. Everyone needs to work with the latest ve
rsion. Changes should not be made to obsolete code causing integration head ache
s.
Each development pair is responsible for integrating their own code when ever a
reasonable break presents itself. This may be when the unit tests all run at 100
% or some smaller portion of the planned functionality is finished. Only one pai
r integrates at any given moment and after only a few hours of coding to reduce
the potential problem location to almost nothing.
Continuous integration avoids or detects compatibility problems early. Integrati
on is a "pay me now or pay me more later" kind of activity. That is, if you inte
grate throughout the project in small amounts you will not find your self trying
to integrate the system for weeks at the project's end while the deadline slips
by. Always work in the context of the latest version of the system.
http://www.extremeprogramming.org/rules/integrateoften.html
Coding Standards
Code must be formatted to agreed coding standards. Coding standards keep the cod
e consistent and easy for the entire team to read and refactor. Code that looks
the same encourages collective ownership.
http://www.extremeprogramming.org/rules/standards.html
Simplicity is the Key

A simple design always takes less time to finish than a complex one. So always d
o the simplest thing that could possibly work next. If you find something that i
s complex replace it with something simple. It's always faster and cheaper to re
place complex code now, before you waste a lot more time on it.
Many people try to measure simplicity. Simple defies measurement because it is a
very subjective quality. One person's simple is another person's complex. Addin
g an advanced technology can simplify one application and make a complete mess o
f another.
Within your project the team decides what is simple. Together you judge your cod
e subjectively. I recommend four subjective qualities; Testable, Understandable,
Browsable, and Explainable (TUBE).
Testable means you can write unit tests and acceptance tests to automatically ch
eck for problems. This impacts the overall design and coupling of objects in you
r application. Break your system into small testable units.
Browsable is the quality of being able to find what you want when you want it. G
ood names helps you find things. Using polymorphism, delegation, and inheritance
correctly helps you find things when you need to.
Understandable is obvious, but highly subjective. A team that has been working w
ith a system a long time will understand it even though someone new is completel
y baffled. So I also recommend explainable as a quality that means it's easy to
show new people how everything works.
Many people recommend a measure of simplicity as: Once and only once. It is impo
rtant to remember this has two parts. Everyone seems to understand the "only
once" part but not the "once and" part. The first part means express all the int
ention of your code even if it means duplication.
Consider a simple example; you multiply by 100 to turn a fraction into percentag
e and you also multiply by 100 to turn meters into centimeters. Should you have
a single function that multiplies by 100 called convertToPercentOrMeters(x)? NO!
Not even if it would remove some duplication. You want two methods; converToPer
cent(aFraction), and convertMetersToCentimeters(aLength). You want two because t
hey tell you different things. Not just that you will multiply by 100 but also w
hy you will multiply by 100 and what kinds of numbers are valid inputs.
One thing about simple designs is that they require knowledge to recognize. Know
ledge is different from information, you can have plenty of information and no k
nowledge. Knowledge is insight into your problem domain that develops over time.
Simple designs often come after the project has been running for a while. The be
st approach is to create code only for the features you are implementing while y
ou search for enough knowledge to reveal the simplest design. Then refactor incr
ementally to implement your new understanding and design.
Keep things as simple as possible as long as possible by never adding functional
ity before it is scheduled. Beware though, keeping a design simple is hard work.
XP Rules
http://www.extremeprogramming.org/rules/simple.html
Unit Tests

Lessons Learned
Unit tests are one of the corner stones of Extreme Programming (XP). But unit te
sts XP style is a little different. First you should create or download a unit t
est framework to be able to create automated unit tests suites. Second you shoul
d test all classes in the system. Trivial getter and setter methods are usually
omitted. You will also create your tests first, before the code.
Unit tests are released into the code repository along with the code they test.
Code without tests may not be released. If a unit test is discovered to be missi
ng it must be created at that time.
The biggest resistance to dedicating this amount of time to unit tests is a fast
approaching deadline. But during the life of a project an automated test can sa
ve you a hundred times the cost to create it by finding and guarding against bug
s. The harder the test is to write the more you need it because the greater your
savings will be. Automated unit tests offer a pay back far greater than the cos
t of creation.
Another common misconception is that unit tests can be written in the last three
months of the project. Unfortunately, without the unit tests development drags
on and eats up those last three months and then some. Even if the time is avail
able good unit test suites take time to
evolve. Discovering all the problems that can occur takes time. In order to have
a complete unit test suite when you need it you must begin creating the tests t
oday when you don't.
Unit tests enable collective ownership. When you create unit tests you guard you
r functionality from being accidentally harmed. Requiring all code to pass all u
nit tests before it can be released ensures all functionality always works. Indi
vidual code ownership is not required if all classes are guarded by unit tests.
Unit tests enable refactoring as well. After each small change the unit tests ca
n verify that a change in structure did not introduce a change in functionality.
Building a single universal unit test suite for validation and regression testin
g enables frequent integration. It is possible to integrate any recent changes q
uickly then run your own latest version of the test suite. When a test fails you
r latest versions are incompatible with the team's latest versions. Fixing small
problems every few hours takes less time than fixing huge problems just before
the deadline. With automated unit tests it is possible to merge a set of changes
with the latest released version and release in a short time.
Often adding new functionality will require changing the unit tests to reflect t
he functionality.

While it is possible to introduce a bug in both the code and test it rarely happ
ens in actual practice. It does occasionally happen that the test is wrong, but
the code is right. This is revealed when the problem is investigated and is fixe
d. Creating tests independent of code, hopefully before code, sets up checks and
balances and greatly improves the chances of getting it right the first time.
Unit Tests provide a safety net of regression tests and validation tests so that
you can refactor and integrate effectively. As they say at the circus; never wo
rk without a net! Creating the unit test before the code helps even further by s
olidifying the requirements, improving developer focus, and avoid creeping elega
nce. Extreme Programming rules
Unit Tests
http://www.extremeprogramming.org/rules/unittests.html
The Customer is Always Available
One of the few requirements of extreme programming (XP) is to have the customer
available. Not only to help the development team, but to be a part of it as well
. All phases of an XP project require communication with the customer, preferabl
y face to face, on site. It's best to simply assign one or more customers to the
development team. Beware though, this seems like a long time to keep the custom
er hanging and the customer's department is liable to try passing off a trainee
as an expert. You need the expert.
User Stories are written by the customer, with developers helping, to allow time
estimates, and assign priority. The customers help make sure most of the system
's desired functionality is covered by stories.
Another Satisfied Customer During the release planning meeting the customer will
need to negotiate a selection of user stories to be included in each scheduled
release. The timing of the release may need to be negotiated as well. The custo
mers must make the decisions that affect their business goals. A release plannin
g meeting is used to define small incremental releases to allow functionality to
be released to the customer early. This allows the customers to try the system
earlier and give the developers feedback sooner.
Because details are left off the user stories the developers will need to talk w
ith customers to get enough detail to complete a programming task. Projects of a
ny significant size will require a full time commitment from the customer.
The customer will also be needed to help with functional testing. The test data
will need to be created and target results computed or verified. Functional test
s verify that the system is ready to be released into production. It can happen
that the system will not pass all functional tests just prior to release. The cu
stomer will be needed to review the test score and allow the system to continue
into production or stop it. A Customer This may seem like a lot of the custo
mer's time at first but we should remember that the customer's time is spared in
itially by not requiring a detailed requirements specification and saved later b
y not delivering an uncooperative system. Some problems can occur when multiple
customers are made available part time. Experts in any field have a tendency to
argue. This is natural. Solve this problem by requiring all the customers to be
available for occasional group meetings to hash out differences of opinion. Codi
ng Standards

http://www.extremeprogramming.org/rules/customer.html

Never Add Functionality Early.

Lessons Learned
Keep the system uncluttered with extra stuff you guess will be used later. Only
10% of that extra stuff will ever get used, so you are wasting 90% of your time.
We are all tempted to add functionality now rather than later because we see ex
actly how to add it or because it would make the system so much better. It seems
like it would be faster to add it now. But we need to constantly remind our sel
ves that we are not going to actually need it. Extra functionality will always s
low us down and squander our resources.
Keeping your code ready for unexpected changes is about simple design. Adding ex
tra flexibility beyond what you need now always makes a design more complex.
Turn a blind eye towards future requirements and extra flexibility. Concentrate
on what is scheduled for today only. XP Rules Don't guess

Portland Pattern Repository


http://www.extremeprogramming.org/rules/early.html
Sequential Integration
Without controlling integration developers test their code and integrate believi
ng all is well. But because of parallel integration there is a combination of so
urce code which has not been tested together before. Integration problems happen
without detection.
Further problems happen when there is no clear cut latest version. This applies
not only to the source code but the unit test suite which must verify the source
code correctness. If you can not lay your hands on a complete, correct, and con
sistent test suite you will be chasing bugs that do not exist and passing up bug
s that do.
You can have developers own specific classes. Class owners integrate and commit
to the repository properly. Interclass dependencies can still be wrong. Class o
wners can become bottle necks if one class requires many changes and it doesn't
solve the whole problem.
Yet another way is to appoint an integrator or integration team. Integrating cod
e from multiple developers is more than a single person can handle. And a team o
f people is too big a resource to integrate more than once a month. In this envi
ronment developers work with obsolete versions which are then erroneously re-int
egrated into the code base.
Many projects use on a source code repository tool to control integration. Most
source code repositories seem to encourage sequential development and parallel i
ntegration. That is, they lock a file so only one developer can add functionalit
y at a time. They allow anyone to
release at anytime because overwrites have been controlled at the individual fil
e level.
These solutions do not address the root problem. You want developers to be able
to proceed in parallel, making changes to any part of the system required, but y
ou also want an error free integration that doesn't loose changes. Like a dozen
steaming locomotives headed for the switching yard at the same time, there is go
ing to be trouble. Instead of restricting development to being sequential in nat
ure let's rethink the problem. Our locomotives can all get into the switching ya
rd without a crash if they just take turns. We need to do this with code integra
tion as well.
Strictly sequential (or single threaded) integration by the developers themselve
s in combination with collective code ownership is a simple solution to this pro
blem. All new code is released to the source code repository by taking turns. Th
at is, only one development pair integrates, tests and commits changes at any gi
ven moment. Single threaded integration allows a latest version to be consistent
ly identified.
This is not to imply that you can not integrate your own changes with the latest
version at your own workstation any time you want. You just can't release your
changes to the team without waiting for your turn.
Development proceeds in parallel while integration is sequential. It seems count
er intuitive to many developers because their experience is that integration tak
es forever so it should be done
Steam Locomotive
as few times as possible. Instead integrate more often so that it is very fast a
nd easy.
Some sort of sequencing mechanism is required. The simplest thing is a single co
mputer dedicated to integration. Development pairs are implicitly sequenced by t
ake turns using it. But a physical token passed from developer to developer also
works. Integrating and releasing code often shortens the time needed to hold th
e lock and thus minimizes the wait time to acquire the lock. XP Rules
http://www.extremeprogramming.org/rules/sequential.html
Release Planning
A release planning meeting is used to create a release plan, which lays out the
overall project. The release plan is then used to create iteration plans for eac
h individual iteration.
It is important for technical people to make the technical decisions and busines
s people to make the business decisions. Release planning has a set of rules tha
t allows everyone involved with the project to make their own decisions. The rul
es define a method to negotiate a schedule everyone can commit to.
The essence of the release planning meeting is for the development team to estim
ate each user story in terms of ideal programming weeks. An ideal week is how lo
ng you imagine it would take to implement that story if you had absolutely nothi
ng else to do. No dependencies, no extra work, but do include tests. The custome
r then decides what story is the most important or has the highest priority to b
e completed.
User stories are printed or written on cards. Together developers and customers
move the cards around on a large table to create a set of stories to be impleme
nted as the first (or next) release. A useable, testable system that makes good
business sense delivered early is desired.
You may plan by time or by scope. The project velocity is used to determine
either
how many stories can be implemented before a given date (time) or how long a set
of stories will take to finish (scope). When planning by time multiply the numb
er of iterations by the project velocity to determine how many user stories can
be completed. When planning by scope divide the total weeks of estimated user st
ories by the project velocity to determine how many iterations till the release
is ready.
Individual iterations are planned in detail just before each iteration begins an
d not in advance. The release planning meeting was called the planning game and
the rules can be found at the Portland Pattern Repository.
When the final release plan is created and is displeasing to management it is te
mpting to just change the estimates for the user stories. You must not do this.
The estimates are valid and will be required as-is during the iteration planning
meetings. Underestimating now will cause problems later. Instead negotiate an a
cceptable release plan. Negotiate until the developers, customers, and managers
can all agree to the release plan.
The base philosophy of release planning is that a project may be quantified by f
our variables; scope, resources, time, and quality. Scope is how much is to be
done. Resources are how many

Extreme Programming flow chart


people are available. Time is when the project or release will be done. And qual
ity is how good the software will be and how well tested it will be.
No one can control all 4 variables. When you change one you inadvertently cause
another to change in response. Note that lowering quality to any less than exc
ellent has unforeseen impact on the other 3 variables that may not become obviou
s until your project slows to a crawl just before the deadline.
In essence there are only 3 variables that you actually want to change. Manageme
nt can set 2 of those variables and the third will be set by the development tea
m. Also let the developers moderate the customers desire to have the project do
ne immediately by hiring too many people at one time
http://www.extremeprogramming.org/rules/planninggame.html
Acceptance Tests
Lessons Learned
Acceptance tests are created from user stories. During an iteration the user sto
ries selected during the iteration planning meeting will be translated into acce
ptance tests. The customer specifies scenarios to test when a user story has bee
n correctly implemented. A story can have one or many acceptance tests, what eve
r it takes to ensure the functionality works.
Acceptance tests are black box system tests. Each acceptance test represents som
e expected result from the system. Customers are responsible for verifying the c
orrectness of the acceptance tests and reviewing test scores to decide which fai
led tests are of highest priority. Acceptance tests are also used as regression
tests prior to a production release.
A user story is not considered complete until it has passed its acceptance tests
. This means that new acceptance tests must be created each iteration or the dev
elopment team will report zero progress.
Quality assurance (QA) is an essential part of the XP process. On some projects
QA is done by a separate group, while on others QA will be an integrated into
the development team

itself. In either case XP requires development to have much closer relationship


with QA.
Acceptance tests should be automated so they can be run often. The acceptance te
st score is published to the team. It is the team's responsibility to schedule t
ime each iteration to fix any failed tests.
The name acceptance tests was changed from functional tests. This better reflect
s the intent, which is to guarantee that a customers requirements have been met
and the system is acceptable. XP Rules!

Portland Pattern Repository


http://www.extremeprogramming.org/rules/functionaltests.html

Вам также может понравиться