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

visual studio team system better software development for agile teams

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 (8.75 MB, 858 trang )

Visual Studio Team System
[SERIES PAGE INSERTED BY A-W]
Better Software Development
for Agile Teams
Will Stott
James Newkirk
Visual Studio
Team System
Upper Saddle River, NJ • Boston • Indianapolis • San Francisco
New York • Toronto • Montreal • London • Munich • Paris • Madrid
Capetown • Sydney • Tokyo • Singapore • Mexico City
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trade-
marks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the
designations have been printed with initial capital letters or in all capitals.
The authors and publisher have taken care in the preparation of this book, but make no expressed or implied war-
ranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or
consequential damages in connection with or arising out of the use of the information or programs contained
herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales,
which may include electronic versions and/or custom covers and content particular to your business, training
goals, marketing focus, and branding interests. For more information, please contact:
U.S. Corporate and Government Sales
(800) 382-3419

For sales outside the United States please contact:
International Sales

Visit us on the Web: www.awprofessional.com
Library of Congress Cataloging-in-Publication Data
Stott, Will.


Visual studio team system : better software development for agile teams / Will Stott, James Newkirk.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-321-41850-0 (pbk. : alk. paper)
1. Microsoft Visual studio. 2. Computer software—Development. 3. eXtreme programming. I. Newkirk,
James. II. Title.
QA76.76.D47S775 2007
005.3—dc22
2007008442
Copyright © 2007 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright, and per-
mission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system,
or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For
information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
75 Arlington Street, Suite 300
Boston, MA 02116
Fax: (617) 848-7047
ISBN 13: 978-0-321-41850-0
ISBN 10: 0-321-41850-6
Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts.
First printing, May 2007
For
Mark Newton Brearley
and
Beth Melanie Newkirk
This page intentionally left blank
Contents at a Glance
Preface xxvii

Acknowledgments xxxv
About the Authors xxxvii
Introduction: Broken Process 1
Section 1: Apply Sharp Tools and Values 9
1 Introduction to Visual Studio Team System 13
2 Agile Values 33
Review of Section 1: Sharp Tools and Values 45
Section 2: Introduce Agile Development 49
3 Overview of Agile Development 53
4 Forming an Agile Team 65
5 Team Foundation Process Frameworks 81
6 Improving Your Process Framework 107
Review of Section 2: Introduce Agile Development 119
Section 3: Use Version Control 123
7 Managing Change 127
8 Setting Up TFS Version Control 149
9 Using TFVC in Your Project 173
10 Policing Your Project with TFVC 191
Review of Section 3: Use Version Control 205
Section 4: Build and Integrate Often 209
11 Building and Integrating Software 213
12 Working with Team Foundation Build 229
Review of Section 4: Build and Integrate Often 255
Section 5: Practice Test-Driven Development 261
13 Introduction to TDD 265
14 Developing Your First Tests 283
vii
15 Learning to Refactor 303
16 Code Coverage and Performance 325
17 Integrating TFP Code with a User Interface 339

Review of Section 5: Practice Test-Driven Development 351
Section 6: Explore by Modeling 357
18 Modeling with Agility 361
19 Creating Models 375
20 Using Models in an Agile Project 395
21 Modeling Solutions with Patterns 415
Review of Section 6: Explore by Modeling 433
Section 7: Implement Customer Testing 439
22 Involving Customers in Testing 443
23 Creating FIT Fixtures 459
24 Running FIT with Team Foundation Build 481
Review of Section 7: Implement Customer Testing 501
Section 8: Estimate, Prioritize, and Plan 507
25 Estimating and Prioritizing Stories 511
26 Agile Planning 527
27 Managing Agile Projects 545
Review of Section 8: Estimate, Prioritize, and Plan 571
Section 9: Practice for Deployment 577
28 Moving into Production 581
29 Developing Installation Programs 597
30 Deployment of Distributed Systems 625
Review of Section 9: Practice for Deployment 661
Section 10: Provide and Reveal Value 665
31 Producing Technical Reports 669
32 Generating Business Value 683
Review of Section 10: Provide and Reveal Value 693
Retrospective: Fixing the Process 697
Section 11: Appendixes 713
A Setting Up VSTS for the Exercises 715
B Software Project Environment for a Small Team 729

C Agile Workspace 753
List of Exercises 763
List of Extreme Programming Practices 771
Glossary 773
Bibliography 789
Resources 797
Index 805
Contents at a Glance
viii
Contents
Preface xxvii
Acknowledgments xxxv
About the Authors xxxvii
Introduction: Broken Process 1
Welcome to the OSPACS Team 1
Team Background 1
Current Organizational Structure and Personas 2
The Team’s Road Map for Fixing Its Process 6
Section 1: Apply Sharp Tools and Values 9
Story from the Trenches 10
1 Introduction to Visual Studio Team System 13
The Purpose and Structure of VSTS 13
Elevator Pitch 14
Typical Organization of VSTS for a Small Team 14
Functional Components of VSTS 16
Client Parts of VSTS 17
Differentiation of VSTS Products 17
Visual Studio Professional 18
Team Explorer 20
VSTS Tools 22

ix
Server Parts of VSTS 27
Team Foundation Server (TFS) 27
Project Portal and Report Sites 27
Team Foundation Build 29
Extending VSTS 30
Visual Studio Industry Partner Program 30
Visual Studio SDK 30
2 Agile Values 33
Tools and Values 33
Buy or Build? 34
Software Values and Traditions 35
The Agile Alliance 36
Extreme Programming (XP) 37
Communication 39
Feedback 40
Courage 41
Simplicity 42
Respect 43
Review of Section 1: Sharp Tools and Values 45
The Team’s Impressions 45
Agile Values 46
Section 2: Introduce Agile Development 49
Story from the Trenches 50
3 Overview of Agile Development 53
What Is Different about an Agile Project? 53
No Separate Development Phases 54
Specifying Requirements with Customer Stories 55
Introduction to Extreme Programming 57
Software Project Life Cycle 58

Iterative and Incremental 58
Iteration and Release Cycles 59
Contents
x
Iterations Deliver Production-Quality Code 60
Project Closure 61
Isn’t XP Just Hacking? 62
Why XP Doesn’t Encourage Hacking 63
4 Forming an Agile Team 65
The Nature of Agile Teams 65
Working As a Design Team 66
Self-Organizing Teams 68
Team Size 68
Work That Doesn’t Suit Agile Teams 69
Agile Team Structure 70
Customer Roles 70
Developer Roles 72
Associated Roles 75
Reorganizing the OSPACS Team 76
Identifying Customers and Developers 76
Rearranging the Office Space 78
5 Team Foundation Process Frameworks 81
Team Projects and Process Frameworks 81
Artifacts Generated When a Team Project Is Created 82
Creating an MSF for Agile Software Development Team Project 85
Deleting a Team Project 87
Giving Users Membership of Your Team Project Groups 88
Gaining Access to Your Team Project Services 89
Administering Your Team Project Security Settings 91
Administering Your TFS Security Settings 92

Connecting to a Team Project 93
Microsoft Solutions Framework (MSF) 4.0 95
Work Item 96
Role 97
Activity 97
Work Stream 97
Tracks and Governance Checkpoints 98
Contents xi
Frameworks for Specific Processes 100
MSF for CMMI Process Improvement 100
MSF for Agile Software Development 102
MSF for XP 102
Process Framework Comparison 103
6 Improving Your Process Framework 107
Providing a New Metric for an Existing Process Framework 107
Adding a New Work Item Type 108
Adding a New Query 109
Improving Your Process 110
Process Template Structure 111
Importing and Exporting Process Templates 112
Changing Your Process Template 115
Review of Section 2: Introduce Agile Development 119
The Team’s Impressions 120
Agile Values 121
Section 3: Use Version Control 123
Story from the Trenches 124
7 Managing Change 127
Sharing Information among Your Team 127
Why You Shouldn’t Keep Source Files in Shared Folders 128
Keeping Source Files in a Repository 129

Using a Version Control System 133
Security 133
Frequent Integration 134
Atomic Check-in 134
Rolling Back Versions 134
Storing Deltas 135
Locking and Merging 136
Labeling and Branching 138
Software Configuration Management 142
Contents
xii
VSTS Support for Version Control Tools 144
Integration with Visual Studio 144
TFVC Features 145
TFS Support for Eclipse and Other Types of IDEs 147
8 Setting Up TFS Version Control 149
Structuring Your Team Project 149
Production and Spike Folders 149
Organization of Visual Studio Solutions, Projects, and Directories 151
Deciding What to Put into Version Control 154
Version Control for Team Documents 156
Archiving Third-Party Libraries 158
Establishing the Initial Baseline for Your Project 160
Adding Files and Directories to Version Control 160
Check In and Label the Baseline 164
Other Set-Up Tasks 166
Importing Source Files 166
Team Project Version Control Options 167
Visual Studio Source Control Options 168
Setting Up Security 169

Backup and Restore 170
9 Using TFVC in Your Project 173
Using TFVC When Coding 173
Sample Programming Episode: Version Control 174
Common Version Control Tasks 177
Using Workspaces 177
Merging Changes 180
Rolling Back to a Previous Version 183
Creating a Branch 185
Creating a Shelve 187
10 Policing Your Project with TFVC 191
Protecting Your Source Code 191
Controlling Access to Individual Files and Folders 192
Setting Check-in Constraints 193
Contents xiii
Establishing Policies for Source Code 195
Coding Standards 195
Static Code Analysis 196
Setting Static Code Analysis As a Check-in Policy 198
Implementing New Coding Standards 200
Updating Static Code Analysis Rules 201
Overriding Check-in Policies 201
Review of Section 3: Use Version Control 205
The Team’s Impressions 206
Agile Values 207
Section 4: Build and Integrate Often 209
Story from the Trenches 210
11 Building and Integrating Software 213
Software Construction 213
Building and Integrating As a Team 214

Automated Build Lab 214
Software Integration and Test Environment 216
Automated Software Testing 217
Smoke Tests 219
Functional Tests 219
Structural (Unit) Tests 220
Quality of Service Tests 220
Integration Testing 221
Build and Test Cycles 222
Local Build 222
Integration Build 225
Daily Build 227
12 Working with Team Foundation Build 229
Welcome to Team Foundation Build 229
Setting Up Team Foundation Build 230
How Team Foundation Build Works 230
The Role of MSBuild 231
Making a Build Validation Test 233
Contents
xiv
Setting Team Build Permissions 235
Creating Team Build Types 237
Scheduling a Daily Build 239
Sample Programming Episode: Integration Build 240
Deleting Build Products 243
Build Management 245
Process Technician Role 245
Build Notification 246
Build Identification 247
Build Reports 248

Scaling Up Team Integration Builds 249
Incremental Builds 250
Optimizing Package Dependencies for Building 251
Review of Section 4: Build and Integrate Often 255
The Team’s Impressions 256
Agile Values 258
Section 5: Practice Test-Driven Development 261
Story from the Trenches 262
13 Introduction to TDD 265
The Nature of Test-Driven Development 265
Settling into the Rhythm of Test-First Programming 265
Top Down versus Bottom Up 268
Simple Test-First Programming Exercises 269
Define the List of Tests 269
Set Up a Basic Test Harness 269
TFP Cycle for the First Test 271
TFP Cycle for the Second Test 273
Review of the Exercises 276
Getting Started with Test-First Programming 277
Applying TFP on Your Team 277
Creating a List of Tests 278
Finding Additional Tests 278
Refactoring 280
Contents xv
14 Developing Your First Tests 283
Creating Visual Studio Projects for TFP 283
How VSTS Supports Unit Testing 283
Setting Up Visual Studio Projects for Unit Testing 285
The Story behind the Tests 287
About the “Image Favorites” Story 288

Dividing the Story into Tasks 288
Create a Test List 289
Finding Your Initial Tests 289
Record the Test List 291
Organization of Your Test List Code 293
Shelving Your Test List Code 293
Implementing the Tests 294
Start with the Easiest Test 294
Fix a Failing Test and Refactor 296
Comments about the Refactoring 299
Do the Next Three Tests Yourself 300
15 Learning to Refactor 303
Doing Small Refactorings 303
Implement a Collection 304
Refactor the Test 306
Refactor the Production Code 308
Safely Changing Code Implementation 309
Comments about the Refactoring 312
Refactor As You Go 313
Implementing More of the Requirement 313
Refactoring Opportunities 316
Doing a Big Refactoring 318
Remove the Middle Man 318
Changing the Type of a Collection 319
Take a Break 322
16 Code Coverage and Performance 325
Code Coverage 325
How to Generate Code Coverage Information 326
Contents
xvi

Performance Analysis 331
Sampling 332
Instrumentation 332
Example Performance Profiling Session 332
Improving Your Library Code’s Performance 335
Improving System Performance 337
17 Integrating TFP Code with a User Interface 339
Implementing the User Interface 339
Define the User Interface 340
Create a Task List 341
Implement the Windows Forms Application 342
Aim to Create a Thin User Interface Layer 344
Simple Design 346
Code Criteria for Simple Design 347
Avoiding Big Design Up Front 348
Review of Section 5: Practice Test-Driven Development 351
The Team’s Impressions 352
Agile Values 354
Reinforcement of Agile Practices 355
Pair Programming 356
Shared Code 356
Single Code Base 356
Ten Minute Build 356
Continuous Integration 356
Section 6: Explore by Modeling 357
Story from the Trenches 358
18 Modeling with Agility 361
Introduction to Modeling 361
Models and Process 362
Values, Principles, and Practices of Agile Modeling 363

Values 363
Principles 363
Practices 364
Contents xvii
Agile Modeling in Use 366
Group Modeling 367
Modeling in Pairs 370
Agile Model-Driven Development 372
19 Creating Models 375
Free-form Diagrams 375
UML Diagrams 377
Class Diagram Notation 377
Sequence Diagram Notation 382
Using Modeling Tools 385
Class Designer 385
Visio for Enterprise Architects 389
Top Ten Tips for Drawing Diagrams 391
20 Using Models in an Agile Project 395
Requirement Models 395
Domain Models and CRC Cards 396
User Interface Models 401
Use Case Models 403
Customer Stories 404
Architectural Models 405
The Architect’s Role on an Agile Team 406
Creating a Skeletal Architectural Model 406
Evolving Your Architectural Model 408
System Metaphor 411
Implementation Models 411
Structural Models 412

Dynamic Models 413
21 Modeling Solutions with Patterns 415
What Is a Pattern? 415
Pattern Languages 416
Example: The Façade Pattern 417
Sources of Patterns 419
Contents
xviii
Using Patterns in an Agile Project 421
Example: Evolving Legacy Code with the Façade Pattern 422
Implementation of Patterns and Models 424
Design Patterns versus Components 425
Reusable Components 425
Emergence of Domain-Specific Languages 426
Use of DSL in Horizontal Market Applications 427
The Language Workbench 427
Software Factories 429
Review of Section 6: Explore by Modeling 433
The Team’s Impressions 434
Agile Values 436
Section 7: Implement Customer Testing 439
Story from the Trenches 440
22 Involving Customers in Testing 443
Agile Customer Testing 443
Testing throughout the Project 444
FIT: Framework for Integrated Test 445
Overview 445
Installing and Running FIT 447
Test Organization 453
Storytest-Driven Development 454

Costs and Benefits of STDD 455
Role of Testers in STDD 457
Relationship of Customer Testing to Your Release Process 457
23 Creating FIT Fixtures 459
Standard FIT Fixtures 459
Column Fixtures: Testing Decisions in the Business Layer 460
Row Fixtures: Testing Lists in the Data Layer 465
Action Fixtures: Testing Workflow in the User Interface Layer 470
Custom FIT Fixtures 476
Example of a Custom Fixture 476
Contents xix
24 Running FIT with Team Foundation Build 481
Performing Customer Tests in Your Build Lab 482
Wrapping FIT in a Generic Test 482
Running a Generic Test in Your Build Lab 485
Automated Customer Testing 487
Running Customer Tests in Team Foundation Build 487
Allowing Your Customers to Edit and Run Tests from Their PCs 489
Introducing Your Team to Customer Testing 491
Discussions around a Whiteboard 492
Putting the Information into a Table 493
Implementing the Fixtures for the Story 495
Using Sequences of Tables in Customer Tests 496
Top Ten Tips for Test Design 498
Review of Section 7: Implement Customer Testing 501
The Team’s Impressions 502
Agile Values 504
Section 8: Estimate, Prioritize, and Plan 507
Story from the Trenches 508
25 Estimating and Prioritizing Stories 511

Working with Customer Stories 511
Overview 512
Generating Stories 514
Estimating 516
Sizing Stories 516
Absolute Values versus Relative Values for Estimation 517
Relative Estimate Scales 519
Task Points and Story Cost Estimation 519
Budgeting 521
Prioritizing 521
Value 522
Business Risk 522
Technical Risk 523
Removing Dependencies 524
Contents
xx
26 Agile Planning 527
The Nature of Plans 527
Plans for Repeated Execution versus One-Time Plans 528
Agile Planning 528
Using Velocity to Measure Rate of Progress 529
Planning at Every Time Scale 530
Task Plan 531
Iteration Plan 534
Release Plan 536
Controlling Plans 538
Levers of Control 539
Story Life Cycle 541
27 Managing Agile Projects 545
Using Visual Studio Team System for Project Management 545

Project Structure 546
Work Item Types and Queries 547
Documents 551
Reports 554
Example Agile Planning Life Cycle 556
Start of Iteration 556
Sample Programming Episode: Task Planning 560
Between Programming Episodes 561
Planning Customer Tests 562
Completing a Story 563
Completing a Bug Fix 563
Daily Meetings 564
End of the Iteration 565
Release Planning 566
Top Ten Tips for Managing Agile Projects 567
Review of Section 8: Estimate, Prioritize, and Plan 571
The Team’s Impressions 572
Agile Values 574
Contents xxi
Section 9: Practice for Deployment 577
Story from the Trenches 578
28 Moving into Production 581
Managing Deployment 581
The Release Process 582
Removing Bottlenecks 585
Handing Over the Release to a Deployment Team 586
Preparing for Deployment 587
The Installation Program 588
Deploying the First Iteration 589
Stubs and Scaffolding 591

Data Deployment 591
Monitoring the Production Environment 592
Logging 593
Creating a Support Web Site 594
29 Developing Installation Programs 597
Introduction to Windows Installer 597
Basic Concepts 598
Principles of Operation 600
Security 602
Creating an Installation Project with InstallShield 604
Using InstallShield with Visual Studio 604
Using the InstallShield IDE 605
Developing Installation Programs on an Agile Team 613
InstallShield Collaboration 614
Automating the Creation of Your Installation Program 619
ClickOnce Technology 620
Suitable Applications 620
Basic Concepts 621
Publishing and Deploying 622
Contents
xxii
30 Deployment of Distributed Systems 625
Distributed System Architecture 625
Distributed Components 626
Service-Oriented Architecture (SOA) 626
System Definition Model (SDM) 627
VSTS Distributed System Designers 628
Logical Datacenter Designer 629
Creating a Logical Model of a Datacenter 629
Endpoints and Servers in Your Toolbox 633

Properties, Settings, and Constraints 634
Importing Settings from Your Existing IIS 636
Application of LDD Models 637
Application Designer 638
Creating an AD Diagram 638
Defining Settings and Constraints 648
Application of AD Models 648
System Designer 649
Creating SD Diagrams 649
Defining Settings and Constraints 652
Application of SD Models 652
Deployment Designer 653
Creating a DD Diagram 653
Deployment Properties 655
Validating Deployment 656
Creating a Deployment Report 657
Application of DD Models 658
Review of Section 9: Practice for Deployment 661
The Team’s Impressions 662
Agile Values 664
Contents xxiii
Section 10: Provide and Reveal Value 665
Story from the Trenches 666
31 Producing Technical Reports 669
Revealing Valuable Information 669
Standard Queries and Reports 670
Gathering and Presenting Information 672
Big Visible Charts 673
Extracting Data from Team Foundation Server 674
Introduction to the TFS Data Warehouse 675

Accessing Data in the TFS Relational Database 676
Creating a Custom Report from the TFS OLAP Database 677
32 Generating Business Value 683
Lean Thinking 683
Specifying Value 684
Identifying the Value Stream 684
Making Value Flow 685
Allowing the Customer to Pull Value 686
Seeking Perfection 686
Changing the Economics of Software Development 688
Value Generated by an Agile Project 689
Value Generated by a Waterfall Project 689
Linking Agile to Other Process Improvement Initiatives 690
Agile Development in the Context of Design for Six Sigma 691
Review of Section 10: Provide and Reveal Value 693
The Team’s Impressions 693
Agile Values 695
Retrospective: Fixing the Process 697
About Retrospectives 697
Preparation 698
Creating a Plan 699
Contents
xxiv

×