Review: The Waterfall Model: (Many Slides Courtesy of Aiken, Bodik, Johnson, Necula)
Review: The Waterfall Model: (Many Slides Courtesy of Aiken, Bodik, Johnson, Necula)
Gather Requirements
Product
Whole process can take a long time before the first working version is seen
Iterative Process: Disadvantages Main risk is making a major mistake in requirements, spec, or design
Because we dont invest as much time before build 1 Begin coding before problem is fully understood
Many systems that are hard to test use something more like a waterfall model
E.g., unmanned space probes
Extreme Programming Waterfall model inspired by civil engineering Civil engineering metaphor is not perfect
Software is more organic than concrete You grow the software to meet changing requirements
Goals Minimize unnecessary work Maximize communication and feedback Make sure that developers do most important work Make system flexible, ready to meet any change in requirements
XP Practices
On-site customer The Planning Game Small releases Testing Simple design Refactoring Metaphor Pair programming Collective ownership Continuous integration 40-hour week Coding standards
XP Process
Short cycle (2 weeks): 1. Meet with client to elicit requirements 2. Planning game
User stories + acceptance tests Break stories into tasks, estimate cost Client prioritizes stories to do first Write programmer tests first Simplest possible design to pass the tests Code in pairs Occasionally refactor the code
3. Implementation
Extreme Programming (XP) XP: like iterative but taken to the extreme
Time
Iterative
XP
Scope
11
Administrivia Grading
20% on homework 30% on mid-term exam 50% on project (more info later)
Mid-term exam in class on 4/12. No finals. Your final demo, report, and presentation will be your finals.
Prof. Sen CS 169 Lecture 3 13
Accounting Software I need an accounting software using which I can create a named account, list accounts, query the account balance, and delete an account. Analyze the CEOs statement and create some user stories
User Stories
Title: Create Account Description: I can create a named account Title: List Accounts Description: I can get a list of all accounts.
15
16
User Stories
Title: Create Account Description: I can create a named account
User Stories
Title: Create Account Description: I can create a named account
17
18
User Stories
Title: Create Account Description: I can create a named account Title: List Accounts Description: I can get a list of all accounts. I can get an alphabetical list of allCan I delete if accounts.
User Stories
Title: Create Account Description: I can create a named account Title: List Accounts Description: I can get a list of all accounts. I can get an alphabetical list of allCan I delete if accounts.
Title: Delete Account Description: I can delete a named account if the balance is zero.
19
20
User Story?
User Story?
Title: Use AJAX for UI Description: The user interface will use AJAX technologies to provide a cool and slick online experience.
Title: Use AJAX for UI Description: The user interface will use AJAX technologies to provide a cool and slick online experience.
21
22
Customer Acceptance Tests Client must describe how the user stories will be tested
With concrete data examples, Associated with (one or more) user stories
User Stories
Title: Create Account Description: I can create a named account Title: List Accounts Description: I can get a list of all accounts. I can get an alphabetical list of all accounts.
Title: Delete Account Description: I can delete a named account if the balance is zero.
23
24
Automate Acceptance Tests Customer can write and later (re)run tests
E.g., customer writes an XML table with data examples, developers write tool to interpret table
26
XP Planning Game
Tasks
Each story is broken into tasks
To split the work and to improve cost estimates
Story: I can create named accounts Tasks: ask the user the name of the account check to see if the account already exists create an empty account
Break down only as much as needed to estimate cost Validate the breakdown of stories into tasks with the customer
Prof. Sen CS 169 Lecture 3 27 Prof. Sen CS 169 Lecture 3 28
Tasks If a story has too many tasks: break it down Team assigns cost to tasks
We care about relative cost of task/stories Use abstract units (as opposed to hours, days) Decide what is the smallest task, and assign it 1 unit Experience will tell us how much a unit is Developers can assign/estimate units by bidding: I can do this task in 2 units
29
30
Planning Game Customer chooses the important stories for the next release Development team bids on tasks
After first iteration, we know the speed (units/ week) for each subteam
Test-driven development Write unit tests before implementing tasks Unit test: concentrate on one module
Start by breaking acceptance tests into units
Pick tasks => find completion date Pick completion date, pick stories until you fill the budget Customer might have to re-prioritize stories
Prof. Sen CS 169 Lecture 3 31
Example of a test
addAccount(checking); if(balance(checking) != 0) throw ; try { addAccount(checking); throw ; Test both good and } catch(DuplicateAccount e) { }; bad behavior
Prof. Sen CS 169 Lecture 3 32
Why Write Tests First? Testing-first clarifies the task at hand Testing forces simplicity
Forces you to think in concrete terms Helps identify and focus on corner cases Your only goal (now) is to pass the test Fight premature optimization Exposes (completely) the programmers intent Courage to refactor code Courage to change code
Fail on beta-testing
Make one or more unit tests from failing scenario
Refactoring: Improving the Design of Code Make the code easier to read/use/modify
Change how code does something
Why?
Incremental feature extension might outgrow the initial design Expected because of lack of extensive early design
No premature optimization
You are not going to need it (YAGNI)
35
36
Refactoring: Remove Duplicated Code Why? Easier to change, understand Inside a single method: move code outside conditionals
if() { c1; c2 } else { c1; c3} c1; if() { c2 } else { c3 }
Examples:
moveRightIfCan, moveRight, canMoveRight
38
Plan your refactoring to allow frequent regression tests Modern tools provide help with refactoring Recommended book: Martin Fowlers Refactoring
Prof. Sen CS 169 Lecture 3 39
40
Pair programming
41
42
Reduces risk
collective understanding of design/code
Evaluation and Planning Run acceptance tests Assess what was completed
How many stories ?
Compute the speed of the team Re-estimate remaining user stories Plan with the client next iteration
46
XP Practices
On-site customer The Planning Game Small releases Testing Simple design Refactoring Metaphor Pair programming Collective ownership Continuous integration 40-hour week Coding standards
Whats Different About XP No specialized analysts, architects, programmers, testers, and integrators
every XP programmer participates in all of these critical activities every day.
47
48
Whats Different About XP Develop infrastructure and frameworks as you develop your application
not up-front quickly delivering business value is the driver of XP projects.
49
50
Conclusion Extreme Programming is an incremental software process designed to cope with change With XP you never miss a deadline; you just deliver less content
Staged waterfall development Generation of project documentation as you go XP planning game to move from customer requirements (user stories) to design specification Test-driven development Refactoring Continuous system integration Pair-programming (encouraged)
Prof. Sen CS 169 Lecture 3 51
52