Tải bản đầy đủ (.pdf) (339 trang)

Pro .NET 2.0 Extreme Programming potx

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (5.29 MB, 339 trang )

Greg Pearman and James Goodwill
Pro .NET 2.0 Extreme
Programming
4800FM.qrk 5/23/06 8:18 PM Page i
Pro .NET 2.0 Extreme Programming
Copyright © 2006 by Greg Pearman and James Goodwill
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-480-3
ISBN-10 (pbk): 1-59059-480-0
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Dominic Shakeshaft
Technical Reviewer: Jason Lefebvre
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick,
Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser,
Keir Thomas, Matt Wade
Project Manager: Sofia Marchant
Copy Edit Manager: Nicole LeClerc
Copy Editor: Marilyn Smith
Assistant Production Director: Kari Brooks-Copony
Production Editor: Kelly Winquist
Compositor: Lynn L’Heureux
Proofreaders: April Eddy, Lori Bring
Indexer: Carol Burbo
Artist: Kinetic Publishing Services, LLC
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski


Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail , or
visit .
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley,
CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail , or visit .
The information in this book is distributed on an “as is” basis, without warranty. Although every precau-
tion has been taken in the preparation of this work, neither the author(s) nor Apress shall have any
liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly
or indirectly by the information contained in this work.
The source code for this book is available to readers at in the Source Code section.
4800FM.qrk 5/23/06 8:18 PM Page ii
To my wife, Simone, my soul mate; to my daughter, Ashley, and my son, Austin.
Thank you for making my life complete. I love you with all my heart.
—Greg Pearman
To my girls Christy, Abby, and Emma.
—James Goodwill
4800FM.qrk 5/23/06 8:18 PM Page iii
4800FM.qrk 5/23/06 8:18 PM Page iv
Contents at a Glance
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
About the Technical Reviewer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Acknowledgments
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
PART 1
■ ■ ■
XP Introduction
■CHAPTER 1 Introducing XP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
■CHAPTER 2 Assembling the Team . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
■CHAPTER 3 Release Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

■CHAPTER 4 Iteration Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
■CHAPTER 5 The Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
PART 2
■ ■ ■
XP Tools
■CHAPTER 6 Build Environment Tool: NAnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
■CHAPTER 7 Test Environment Tool: NUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
■CHAPTER 8 Simulation Environment Tool: NMock . . . . . . . . . . . . . . . . . . . . . . . . . . 69
■CHAPTER 9 Automation Environment Tool: CruiseControl.NET . . . . . . . . . . . . . . . 83
■CHAPTER 10 Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
PART 3
■ ■ ■
XP in Action
■CHAPTER 11 Release Planning—The Journey Begins . . . . . . . . . . . . . . . . . . . . . . 111
■CHAPTER 12 Iteration Planning for the First Iteration . . . . . . . . . . . . . . . . . . . . . . . 133
■CHAPTER 13 First Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
■CHAPTER 14 Iteration Planning for the Second Iteration . . . . . . . . . . . . . . . . . . . . 201
■CHAPTER 15 Second Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
■APPENDIX A Preparing Your Development Environment . . . . . . . . . . . . . . . . . . . . 279
■APPENDIX B .NET C# Coding Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
■APPENDIX C XP Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
v
4800FM.qrk 5/23/06 8:18 PM Page v
4800FM.qrk 5/23/06 8:18 PM Page vi
Contents
About the Authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
About the Technical Reviewer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Acknowledgments

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
PART 1
■ ■ ■
XP Introduction
■CHAPTER 1 Introducing XP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
The Waterfall Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
The Agile Methodologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
What Is XP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Four XP Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Fifteen XP Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Fourteen XP Practices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Other Agile Methodologies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Lean Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Dynamic Systems Development Method . . . . . . . . . . . . . . . . . . . . . . 15
Adaptive Software Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Crystal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Scrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Feature Driven Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Is XP the Best Agile Method? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
When Shouldn’t You Use XP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
vii
4800FM.qrk 5/23/06 8:18 PM Page vii
■CHAPTER 2 Assembling the Team . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
XP Roles and Responsibilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Customer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Development Coach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
The Business Coach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The Developer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
The System Engineer/Business Analyst . . . . . . . . . . . . . . . . . . . . . . . 23

The Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
The Tester . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
The Big Boss . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Team Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Your XP Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
■CHAPTER 3 Release Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
The Exploration Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
User Story Writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
User Story Estimating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
The Planning Game . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Story Prioritization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Velocity Determination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
User Story Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
The Release Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
■CHAPTER 4 Iteration Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Iteration Velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Story Subselection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Task Determination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Task Assignment and Estimation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Task Points and Task Point Velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Task Sign-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Iteration Balancing
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
The Iteration Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
■CONTENTSviii
4800FM.qrk 5/23/06 8:18 PM Page viii

■CHAPTER 5 The Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
What Is an Iteration? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Design Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Stand-Up Meetings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Paired Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Test, Code, and Refactor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Building Tests and Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Keeping the Customer Involved . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Acceptance Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Tracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Coaching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
PART 2
■ ■ ■
XP Tools
■CHAPTER 6 Build Environment Tool: NAnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
What Is NAnt? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Installing NAnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Creating a Build File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Understanding the Build File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Saving the Build File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Testing the Build File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
■CHAPTER 7 Test Environment Tool: NUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
What Is NUnit? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Installing NUnit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Building a Unit Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Creating the Test Class
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Creating the Application Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

Integrating with NAnt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Running the Build File
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
■CONTENTS ix
4800FM.qrk 5/23/06 8:18 PM Page ix
■CHAPTER 8 Simulation Environment Tool: NMock . . . . . . . . . . . . . . . . . . . . . 69
What Is NMock? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Installing NMock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Creating a Mock Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Defining an Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Creating the Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Incorporating NMock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Running the Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
■CHAPTER 9 Automation Environment Tool: CruiseControl.NET . . . . . . . 83
What Is CCNet? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Installing CCNet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Setting Up the CCNet Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Creating the CCNet Configuration File
. . . . . . . . . . . . . . . . . . . . . . . . . 84
Starting the CCNet Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Setting Up CCTray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Starting CCTray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Configuring CCTray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Using CCTray . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Setting Up the Web Dashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Installing the Web Dashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Running the Web Dashboard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

■CHAPTER 10 Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Visual Studio 2005 and Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Extract Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Rename . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Encapsulate Field
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
Extract Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Promote Local Variable to Parameter . . . . . . . . . . . . . . . . . . . . . . . . 105
Remove Parameters
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Reorder Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
■CONTENTSx
4800FM.qrk 5/23/06 8:18 PM Page x
PART 3
■ ■ ■
XP in Action
■CHAPTER 11 Release Planning—The Journey Begins . . . . . . . . . . . . . . . . . 111
Business Problem Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
Story Writing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Helping the Customer Write the Stories . . . . . . . . . . . . . . . . . . . . . . 113
Creating a High-Level Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Comparing the Stories with the Mission . . . . . . . . . . . . . . . . . . . . . . 123
Story Estimating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Reviewing Each Story . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Getting the Big Picture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Declared Velocity
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Story Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Prioritizing the Stories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

Selecting a Subset of Stories
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Refining the Subset Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Coach’s Journal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
■CHAPTER 12
Iteration Planning for the First Iteration
. . . . . . . . . . . . . . . . . 133
Story Selection
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
Story Tasking and Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Breaking Up the Stories into Tasks
. . . . . . . . . . . . . . . . . . . . . . . . . . 136
Signing Up for Tasks
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Iteration Balancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Coach’s Journal
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
■CHAPTER 13 First Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Daily Stand-Ups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Design Meeting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Developers’ Duties: Pair Up and Test, Code, and Refactor . . . . . . . . . . . 150
Developing the Login User Story . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Developing the Browse Catalog User Story . . . . . . . . . . . . . . . . . . . 168
Developing the Remaining User Stories . . . . . . . . . . . . . . . . . . . . . . 198
■CONTENTS xi
4800FM.qrk 5/23/06 8:18 PM Page xi
Other Team Members’ Duties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

Acceptance Tester . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Customer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Coach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Coach’s Journal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
■CHAPTER 14 Iteration Planning for the Second Iteration . . . . . . . . . . . . . . 201
Velocity Adjustment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Story Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Story Tasking and Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Breaking Up the Stories into Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Signing Up for Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Iteration Balancing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Coach’s Journal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
■CHAPTER 15 Second Iteration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Refactoring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Design Meeting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Developers’ Duties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Developing the Display Checkout Confirmation User Story . . . . . . 220
Acceptance Testing
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Developing the Remaining User Stories . . . . . . . . . . . . . . . . . . . . . . 277
Coach’s Journal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
■APPENDIX A Preparing Your Development Environment . . . . . . . . . . . . . . 279
Visual Studio Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Creating the Northwind Solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

Creating the DataLayer Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Creating the BusinessLayer Project . . . . . . . . . . . . . . . . . . . . . . . . . . 282
Creating the NorthwindWeb Project . . . . . . . . . . . . . . . . . . . . . . . . . 284
Creating the TestLayer Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Running a Unit Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286
■CONTENTSxii
4800FM.qrk 5/23/06 8:18 PM Page xii
fa938d55a4ad028892b226aef3fbf3dd
The Database Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Setting Up the ODBC Data Source . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Connecting to the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292
Browsing the Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
■APPENDIX B .NET C# Coding Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Naming Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297
Indentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
White Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Solution and Project Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303
■APPENDIX C XP Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Websites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305
Mailing Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
Conferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
■CONTENTS xiii
4800FM.qrk 5/23/06 8:18 PM Page xiii
4800FM.qrk 5/23/06 8:18 PM Page xiv
About the Authors
■GREG “HAP” PEARMAN is the founder of Spotted Dog Software LLC, located

in Littleton, Colorado. He has more than 18 years of experience in archi-
tecting and developing enterprise software solutions. Formerly a senior
architect and developer at Qwest Communications, Greg was a leading
member of a small, elite team that developed and implemented Extreme
Programming (XP) practices for the entire Qwest IT organization. This
team worked with each Qwest IT project team to teach them XP and to
follow up with those teams in the field after their training. This experience gave Hap the
unique opportunity to stress-test XP under multiple and varying circumstances as an XP
coach and mentor.
Greg has also architected and developed small to large enterprise systems using tech-
nologies such as J2EE, .NET (C#), Cocoa, and C++ for various companies, including IBM, EPA,
US West Direct, Hertz, VeriSign, and ABC/Disney.
■JAMES GOODWILL is a renowned technologist and experienced open source leader. James is a
member of the JSR-152 Expert Group and is a frequent speaker at major conferences such as
ApacheCon, Comdex, and multiple Java Users Groups. He has provided technical and business
leadership to many Global 2000 organizations, including QualCOMM, BellSouth, MCI, and BEA
Systems. Books that James has authored include Mastering Jakarta Struts (John Wiley and Sons,
2002), Apache Jakarta-Tomcat (Apress, 2001), and Apache Axis Live (SourceBeat, 2004).
xv
4800FM.qrk 5/23/06 8:18 PM Page xv
4800FM.qrk 5/23/06 8:18 PM Page xvi
About the Technical Reviewer
■JASON LEFEBVRE is vice president and founding partner of Intensity Software, Inc.
(www.intensitysoftware.com), which specializes in providing custom Microsoft .NET
applications, IT consulting services, legacy system migration, and boxed software products
to a rapidly growing set of clients. Jason has been using .NET since its alpha stages in early
2000 and uses Visual Studio and the .NET Framework daily while creating solutions for
Intensity Software’s clients. Jason has been a participating author for a number of books
and has written numerous articles about .NET-related topics.
xvii

4800FM.qrk 5/23/06 8:18 PM Page xvii
4800FM.qrk 5/23/06 8:18 PM Page xviii
Acknowledgments
First and foremost, to my personal Lord and Savior, Jesus Christ, through whom all things are
possible. I would like to give a big thanks to Paul Karsten (The Big Kahuna) for being a great
role model. You are the XP coach of all XP coaches. Thanks goes to the rest of the original
Piranhas (Carl Podlogar, Charles Kastner, Joel Fredrick, Ken Conway, Rebecca Germain,
Andy Ochsner, and Roger Burnett), too. You guys made XP fun and real for me.
Thanks to Owen Rogers for all your help with NMock. You guys at ThoughtWorks are
doing a great job for the development community.
Thanks to Gina Jackson for all her hard work on creating legible user story cards for the
book. You always had a smile for me when I asked you for just one more set of cards.
Lastly, I would like to thank my dad. You gave me the character, values, and strength I
have today. I miss you.
Greg Pearman
I would like to thank the people who made this book a success. They are the people who took my
words and shaped them into something that I hope will help you use Extreme Programming to
its fullest. I would like to especially thank everyone at Apress for their patience during the devel-
opment of this text. Each and every person made this book what it is today.
On a closer note, I would like to thank everyone at my company, Virtuas Solutions, LLC,
for their support while I was completing this text. The entire “UNREAL” staff contributed by
picking up my assignments when my plate was too full. I want to also thank Hap for his con-
tribution to this text. It was a lot of fun working with a qualified coauthor.
Finally, the most important contributors to this book are my wife, Christy, and our
daughters, Abby and Emma. They are the ones who really sacrificed during the development
of this text. They are the ones who deserve the credit for this book. With their support, I can
do anything.
James Goodwill
xix
4800FM.qrk 5/23/06 8:18 PM Page xix

4800FM.qrk 5/23/06 8:18 PM Page xx
XP Introduction
PART 1
■ ■ ■
4800ch01.qrk 5/15/06 8:46 PM Page 1
4800ch01.qrk 5/15/06 8:46 PM Page 2
Introducing XP
Many books cover the theory of Extreme Programming (XP). This is not one of them. If you
are picking up this book hoping to learn about the philosophy of XP, you will be disappointed.
This book concentrates on the practical, not the theoretical. We hope to leave you with the
knowledge of how to implement XP in a practical manner. But before we do this, we need to
give you a clear, no-nonsense definition of XP.
To put XP in context, we’ll begin by looking briefly at the waterfall and Agile methods of
software development. Each methodology has many books dedicated to it, of course. Here, we
will give you just enough information to understand how and why XP came to exist.
Then we’ll answer the question “What is XP?” We’ll look at all of the specific key values,
principles, and practices of XP. You’ll know what XP is after you have read this section!
Next, we’ll offer you a comparison between XP and some other current Agile methods.
Finally, we’ll address when it’s best to use XP.
The Waterfall Methodology
The waterfall methodology is a software development process that is broken up into a series of
distinct phases, with each phase existing as an autonomous phase with respect to all subsequent
phases. In a waterfall project, all phases of the process have a distinct beginning and end. When
a phase is over, the subsequent phase begins. This stepped approach continues throughout the
remaining phases of a project until it reaches completion.
Several characteristics of the waterfall methodology often create some undesirable results:
• Each phase of a waterfall project must be complete prior to moving to the next phase.
This approach makes it difficult for you to learn and adjust to changes in the project
requirements.
• The waterfall methodology is very heavily focused on process. This approach often

causes the team to concentrate more on managing the waterfall processes, as opposed
to fulfilling the goals of the project.
• The waterfall methodology is focused on documentation as one of its primary forms of
communication. Unfortunately, software development is often a complicated matter
and is difficult to capture entirely on paper. Additionally, what is not said, or written in
this case, can be as powerful as what is said, but that type of information is not cap-
tured in a document.
3
CHAPTER 1
■ ■ ■
4800ch01.qrk 5/15/06 8:46 PM Page 3
• Extensive documentation is also used as a means of trying to control scope. In the analy-
sis phase, requirements documents are used as contracts between software developers
and the project stakeholders. This requires the project stakeholders to know exactly what
they want and to have those needs and wants remain constant throughout the develop-
ment life cycle. This is rarely the case.
• The waterfall methodology assumes that a project can be managed by a predefined
project plan. Months are spent perfecting the plan before any work on the project really
begins. A lot of work is put into maintaining the plan throughout the project, and often
the plan is out of date with the current status of the project. The end result is the project
plan tends to be more of a historical document than a working guide to the develop-
ment team. Planning is not the problem; the problem is trying to predict and plan for
the future.
While the waterfall approach does have problems, it did start with the best intentions—
bringing order out of chaos. When waterfall methods were first employed, there was no
software process at all in place. Having some processes, documentation, and a plan is not a
bad thing. Unfortunately, the waterfall methodology swung the pendulum too far to the right.
Software projects need to be manageable, but without becoming too brittle or complicated to
implement—which is exactly what the first waterfall methods created. This swing resulted in
the development of another group of methodologies, known as Agile methods.

The Agile Methodologies
Agile methods were born out of the frustration software development teams were having with
the waterfall approach. These software developers were not seeing the results they felt were
necessary to deliver successful projects on a regular basis. They saw several shortcomings with
this heavy emphasis on process and documentation.
Several developers who shared the same frustrations with waterfall approaches got together
and formed the Agile Alliance. The alliance members agreed on four key values that they felt all
Agile projects should have in common. They called the compilation of these values the Agile
Manifesto (). The values of the Agile Manifesto are as follows:
Individuals and interactions over Processes and tools
Working software over Comprehensive documentation
Customer collaboration over Contract negotiation
Responding to change over Following a plan
The idea is that by focusing on the values on the left, you shift your approach to software
development. It’s not that the items on the right are wrong or bad, but that the items on the
left should be more important.
With the increasing popularity of the Internet and e-commerce, businesses are migrating
to the Web in alarming rates. With this migration comes the need for rapid deployment of soft-
ware. In addition, changes in the economy have required development teams to do more with
less. Handling these changes gracefully is the focus of the Agile methods.
We’ll return to Agile methods as a group at the end of the chapter and see when it’s best to
use XP over the various other Agile methods.
CHAPTER 1 ■ INTRODUCING XP4
4800ch01.qrk 5/15/06 8:46 PM Page 4
What Is XP?
Extreme Programming, XP for short, is an Agile software development methodology that is
made up of a collection of core values, principles, and practices that provide a highly efficient
and effective means of developing software. At the core of XP is the desire to embrace the
change that naturally occurs when developing software. XP differs from other Agile method-
ologies because it defines an implementation strategy for practicing the four core Agile values

on a daily basis.
Four XP Values
XP defines four key values. These values are important because they form the foundation on
which all XP principles and practices are built. Each of these values is described in the follow-
ing sections.
XP Value 1: Communication
One of the key factors of software development teams that are highly successful is their ability
to communicate effectively. Teams that communicate often in an open and honest environ-
ment are able to make effective decisions and mitigate problems more quickly than teams
that don’t have that type of communication.
Communication comes in several forms: written, spoken, gestures, and body posture.
Traditionally, these types of communications can be executed in several fashions: formal doc-
umentation, e-mail, telephone, video conferencing, and face-to-face conversation. While all of
these forms of communication are useful, XP favors face-to-face communication.
XP Value 2: Simplicity
Another key factor of software development teams that are highly successful is their ability to
make what they do as simple as possible. This includes the code they develop, the documenta-
tion they produce, the processes they use, and the form of communication they choose.
Simplicity forces the team to build what is needed to satisfy requirements as they are defined
today, as opposed to building unnecessary features that may never be needed.
The result of keeping things simple is a reduction in code, processes, and documentation,
which, in turn, leaves additional time to incorporate more features into the system. After all,
the project stakeholders are paying for system features, not code with functionality they did
not request.
XP Value 3: Feedback
Feedback is the XP value that helps the team members know if they are on the right track. This
is why feedback needs to be highly repetitive and frequent. In XP, feedback comes not only
from individuals and their interactions, but also from the automation of tests, the progress
charts that the tracker generates, and the successful acceptance of user stories.
CHAPTER 1 ■ INTRODUCING XP 5

4800ch01.qrk 5/15/06 8:46 PM Page 5

×