Writing Effective User Stories For Agile Requirements

Transcription

Writing Effective User Storiesfor Agile RequirementsMike CohnSeptember 26, 2005Mike Cohn—background Programming for 20 yearsAuthor of Founding member and directorof the Agile Alliance and theScrum AllianceFounder of Mountain GoatSoftware 2User Stories AppliedAgile Estimating and PlanningJava, C , database programmingbooksProcess and project managementconsulting and trainingAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn1

Today’s agenda Whatuser stories are Users and user roles Gathering stories INVEST in good stories Why user stories?All slides copyright 2000-2005, Mountain Goat Software3Slides copyright 2000-2004, Michael W. CohnRon Jeffries’ Three Cs4Card Stories are traditionallywritten on note cards. Cards may be annotatedwith estimates, notes, etc.Conversation Details behind the storycome out duringconversation with customerConfirmation Acceptance tests confirmthe story was codedcorrectlyAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn2

Samples – Travel reservation systemAs a user, I can reserve ahotel room.As a user, I can cancel areservation.As a vacation planner, Ican see photos of thehotels.As a user, I can restrictsearches so that I onlysee hotels with availablerooms.All slides copyright 2000-2005, Mountain Goat Software5Slides copyright 2000-2004, Michael W. CohnWhere are the details? As a user, I can cancel a reservation. Does the user get a full or partial refund?Is the refund to her credit card or is it site credit? Howfar ahead must the reservation becancelled?Is that the same for all hotels? For all site visitors? Can frequent travelers cancellater? Is 6a confirmation provided to the user?How?All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn3

Details added in smaller “sub-stories”As a premium sitemember, I cancancel a reservationup to the last minute.As a user, I cancancel areservation.As a non-premiummember, I cancancel up to 24hours in advance.As a site visitor, I amemailed aconfirmation of anycancelled reservation.All slides copyright 2000-2005, Mountain Goat Software7Slides copyright 2000-2004, Michael W. CohnDetails added as tests High level tests are added to the story Can be used to express additional details and expectationsAs a user, I can cancel a reservation. Verify that a premium member can cancel thesame day without a fee. Verify that a non-premium member is charged10% for a same-day cancellation. Verify that an email confirmation is sent. Verify that the hotel is notified of any cancellation.8All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn4

Today’s agenda Whatuser stories are Users and user roles Gathering stories INVEST in good stories Why user stories?All slides copyright 2000-2005, Mountain Goat Software9Slides copyright 2000-2004, Michael W. Cohn“The User” Many projects mistakenly assume there’sonly one user: “Theuser”Write all stories from one user’sperspective Assume all users have the same goals Leads to missing stories 10All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn5

Travel Site—Who’s the user?MaryLauraFrequent flier whonever knows whereshe’ll beWants to scheduleher family’s annualvacationJimFrequent flier whoflies every week butalways to the sameplaceHowardDominicMary’s assistant;books herreservationsHotel chain VicePresident; wants tomonitor reservationsAll slides copyright 2000-2005, Mountain Goat Software11Slides copyright 2000-2004, Michael W. CohnUser roles Broaden the scope from looking at one userAllows users to vary by Whatthey use the software for How they use the software Background Familiarity with the software / computers Used extensively in usage-centered designDefinition Auser role is a collection of defining attributes thatcharacterize a population of users and their intendedinteractions with the system.Source: Software for Use byConstantine and Lockw ood (1999).12All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn6

Common attributesInfrequentVacation PlannerMaryLauraFrequent flier who Frequent Fliernever knows whereJimshe’ll beSchedulerWants to scheduleher family’s annualvacationFrequent flier whoflies every week butRepeatalwaysto Travelerthe sameplaceInsiderHowardDominicMary’s assistant;books herreservationsHotel chain VicePresident; wants tomonitor reservationsAll slides copyright 2000-2005, Mountain Goat Software13Slides copyright 2000-2004, Michael W. CohnUser role brainstorming Brainstorming meeting Customer,developers, anyone whounderstands a product’s intended usersEveryone grabs a stack of cards Write role names on cards As fast as possible and with no judgmentNo turns Placecard on table Call out role name as you place it14All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn7

User role brainstormingWe’ve been hired by fBay to create “the bestnew web auction site since eBay.” Brainstorm the user roles who willinteract with this site.All slides copyright 2000-2005, Mountain Goat Software15Slides copyright 2000-2004, Michael W. CohnUser role modeling steps Brainstorman initial set of user roles Organize the initial set Consolidate roles Refine roles16All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn8

Organize the initial set Arrange cards spatially to indicateoverlapping and similar roles Useany arrangement rules you wantCollege gradFirst timerLayoff victimJob posterResumereaderRecruiterGeographicsearcherJob seekerMonitorSys AdminAll slides copyright 2000-2005, Mountain Goat Software17Slides copyright 2000-2004, Michael W. CohnConsolidate rolesDiscuss what is meant by each card Arrange cards spatially to indicateoverlapping and similar roles Use any arrangement rules you wantLook for cards to Combine Replace 18with a more generic/different cardEliminate cards that are unimportant tothe success of the productAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn9

Consolidating–an exampleCollegeJob seekergradFirst timerJob posterLayoffFirst ffvictimExternalrecruiterJob seekerMonitorResumereaderRecruiterSys AdminGeographicsearcher19All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. CohnOrganize and consolidate1) Organize your initial set of user roles forfBay.2) Consolidate the user roles.20All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn10

Advantages of using rolesUsers becometangibleStart thinking of softwareas solving needs of realpeople.Avoid saying “theuser”Instead we talk about “afrequent flier” or “a repeattraveler”Incorporate rolesinto stories“As a role , I want story so that benefit .All slides copyright 2000-2005, Mountain Goat Software21Slides copyright 2000-2004, Michael W. CohnToday’s agenda Whatuser stories are Users and user roles Gathering stories INVEST in good stories Why user stories?22All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn11

Gathering stories Common metaphors for requirements arewrong “Elicitingrequirements” “Capturing requirements” These metaphors imply Usersknow the requirements but don’t wantto tell us Requirements need to be locked up once“captured”All slides copyright 2000-2005, Mountain Goat Software23Slides copyright 2000-2004, Michael W. CohnThe proper metaphor Trawling† for requirements Trawl: “sift through as part of a search” (OAD)Metaphor captures these aspects: Requirementscan be captured with differentsized nets Requirements change, mature, possibly die Skill is a factor†Mastering the Requirements Processby Suzanne and James Robertson,1999.24All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn12

A little is enough, or is it?Agile processes acknowledge that wecannot trawl with such a fine net that wecan write all the user stories upfront However, Thisdoesn’t mean we shouldn’t write asmany as we canAll slides copyright 2000-2005, Mountain Goat Software25Slides copyright 2000-2004, Michael W. CohnTechniques for trawling for storiesQuestionnairesObservationUser interviewsStory-writingworkshops26All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn13

QuestionnairesGood technique for learning more aboutstories you already have If you have a large user base, great wayto get information to help prioritize stories Not effective as a primary means oftrawling for new stories All slides copyright 2000-2005, Mountain Goat Software27Slides copyright 2000-2004, Michael W. CohnObservationGreat way to pick up insights Two approaches Justobserve, with or without user’sknowledge Have the user demonstrate to a group howshe uses the software28All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn14

Observation example Stated need: “We need a large text field to summarize.”Observed need: Havethe system record the user’s choicesAll slides copyright 2000-2005, Mountain Goat Software29Slides copyright 2000-2004, Michael W. CohnInterviewsDefault approach taken by many teams Selection of interviewees is critical Tryto interview as many user roles aspossible Cannot just ask “So whaddaya want?” Mostusers are not adept at understandingtheir true needs30All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn15

Context matters“My wife and Isplit up ”“He’s no longerwith us ”All slides copyright 2000-2005, Mountain Goat Software31Slides copyright 2000-2004, Michael W. CohnMy context isn’t your context“Dad,make itwarmer.”32You hear “Increase the temperature”He meant “Move the temperaturecloser to what we call warm.”All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn16

A horrible question This question sucked two years out of mylife“Would you like itin a browser?”“Of course, nowthat you mention it!”All slides copyright 2000-2005, Mountain Goat Software33Slides copyright 2000-2004, Michael W. CohnWe can do better“What would you think of having this app in abrowser rather than as a native Windowsapplication even if it means reducedperformance, a poorer overall user experience,and less interactivity?” It’s open 34Full range of answersBut it has too much contextAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn17

The best way to ask“What would you be willing to giveup in order to have it in a browser?” We want to ask questions that are Open-ended Context-freeAll slides copyright 2000-2005, Mountain Goat Software35Slides copyright 2000-2004, Michael W. CohnBeware of assumptionsWhat time did the sun rise in Boston, MA,on October 10, 1582? Draw a single line that crosses each linesegment in this figure exactly once: 36All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn18

Seeking a solution “Dad, do you know the answer?”All slides copyright 2000-2005, Mountain Goat Software37Slides copyright 2000-2004, Michael W. CohnIt’s my problem, I know the solutionHaving a problem does not uniquelyqualify you to solve it “It hurts when I go like this ” 38All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn19

We need to stop asking usersSince users don’t know how to solve theirproblems, we need to stop asking We need to involve them instead Empirical designParticipatory design Designers of the new systemmake decisions by studyingprospective users in typicalsituations The users of the system becomepart of the team designing thebehavior of the systemAll slides copyright 2000-2005, Mountain Goat Software39Slides copyright 2000-2004, Michael W. CohnStory-writing workshopsIncludes developers, users, customer,others Goal is to write as many stories aspossible No 40prioritization at this pointUses low-fidelity prototyping andbrainstorming techniquesAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn20

Start with epics and iterateAs a frequent flyer,I want to seecheck my account.FrequentFlyerAs a frequent flyer,I want to book atrip.As a frequent flyer,I want to book atrip using miles.As a frequent flyer,I want to re-book atrip I make often.As a frequent flyer,I want to requestan upgrade.As a frequent flyer,I want to see if myupgrade cleared. Epic #3 All slides copyright 2000-2005, Mountain Goat Software41Slides copyright 2000-2004, Michael W. CohnA low-fidelity prototypeNewsHome PageNewsHot DealsSearch Fields42Hot Deal DetailsLocation infoWeatherWeatherHotel ResultsList of hotelsBlurb abouteachHotel DetailsInfo about hotelMapLocal attractionsAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn21

Low-fidelity prototyping Use paper, note cards, white board, big PostitsPrototype is of components or areas withinthe application, not of actual screens HotelResults could be on Home Page or be aseparate page Doesn’t require knowledge of how screenswill lookThrow it away a day or two laterWorks better to go depth-firstAll slides copyright 2000-2005, Mountain Goat Software43Slides copyright 2000-2004, Michael W. CohnCreating the low-fidelity prototype Start with an empty box: “Here’s the main screen in the system”Ask open-ended, context-free questions as yougo: Whatwill the users most likely want to do next? What mistakes could the user make here? What could confuse the user at this point? What additional information could the user need? 44Consider these questions for each user roleAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn22

A mini story-writing workshopWrite some user stories for fBay based onthe roles you identified.Tip: try this template:“As a role , I want to story so that benefit .”All slides copyright 2000-2005, Mountain Goat Software45Slides copyright 2000-2004, Michael W. CohnToday’s agenda Whatuser stories are Users and user roles Gathering stories INVEST in good stories Why user stories?46All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn23

What makes a good story? Independent NegotiableINVEST Valuable Estimatable Small TestableThanks to Bill Wake for theacronym. See www.xp123.com.All slides copyright 2000-2005, Mountain Goat Software47Slides copyright 2000-2004, Michael W. CohnIndependent Avoid introducing dependencies Leadsto difficulty prioritizing and planningA company can payfor a job posting witha Visa card.A company can pay?for a job posting withan AmEx card.A company can payfor a job posting? witha MasterCard. The first of thesestories will take 3 daysto develop It doesn’t matterwhich is first The others will take 1day?48All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn24

Making stories independentCombine the storiesSplit across adifferent dimensionWrite two estimatesand move on A customer can pay with a credit card. A customer can pay with one type ofcredit card. A customer can pay with two othertypes of credit cards. 3 days if first; 1 otherwiseAll slides copyright 2000-2005, Mountain Goat Software49Slides copyright 2000-2004, Michael W. CohnNegotiable Stories are not Written contracts Requirements the software must fulfillDo not need to include all detailsToo many details give the impressions of false precision or completeness that there’s no need to talk further Need some flexibility so that we can adjust howmuch of the story gets implemented Ifthe card is contract then it needs to be estimatedlike a contract50All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn25

Is this story negotiable?Print dialog allows the user to edit theprinter list. The user can add or removeprinters from the printer list. The user canadd printers either by auto-search ormanually specifying the printer DNS nameor IP address. An advanced search optionalso allows the user to restrict his searchwithin specified IP addresses and subnetrange.All slides copyright 2000-2005, Mountain Goat Software51Slides copyright 2000-2004, Michael W. CohnValuable 52Stories must be valuable to either:Users As a user, I can search for a job by titleand salary range.Purchasers Throughout the project, the team willproduce documentation suitable foran ISO 9001 audit. The development team will producethe software in accordance withCMM level 3. All configuration information is readfrom a central location.All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn26

Stories valued by developers Should be rewritten to show the benefitAll connections to thedatabase are througha connection pool.Up to 50 users shouldbe able to use theapplication with a fiveuser database license.All error handling andlogging is donethrough a set ofcommon classes.All errors arepresented to the userand logged in aconsistent manner.All slides copyright 2000-2005, Mountain Goat Software53Slides copyright 2000-2004, Michael W. CohnEstimatableBecause stories are used in planning A story may not be estimatable if: Developers lackdomain knowledge As a new user, I am given adiabetic screening.Developers lacktechnical knowledge As a site visitor, I can elect tosee all text in a larger font.The story is too big54 As a user, I can find a job.All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn27

Small Large stories (epics) are hardto estimate hard to plan Compound story An They don’t fit well into single iterationsepic that comprises multiple shorter storiesComplex story Astory that is inherently large and cannot easily bedisaggregated into constituent storiesAll slides copyright 2000-2005, Mountain Goat Software55Slides copyright 2000-2004, Michael W. CohnCompound stories Often hide a great number of assumptionsAs a user, I canpost my resume.56 A resume includes separatesections for education, priorjobs, salary history,publications, etc. Users can mark resumes asinactive Users can have multipleresumes Users can edit resumes Users can delete resumesAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn28

Splitting a compound storySplit along operationalboundaries (CRUD) As a user, I can create resumes, which includeeducation, prior jobs, salary history, publications,presentations, community service, and anobjective. As a user, I can edit a resume. As a user, I can delete a resume. As a user, I can have multiple resumes. As a user, I can activate and inactivate resumes.57All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. CohnSplitting a compound story, cont.Split along data boundaries As a user, I can add and edit educationalinformation on a resume. As a user, I can add and edit prior jobs on aresume. As a user, I can add and edit salary history on aresume. As a user, I can delete a resume. As a user, I can have multiple resumes. As a user, I can activate and inactivate resumes.58All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn29

Other ways to split large storiesRemove cross-cutting concerns Don’t meet performance targets Avoid splitting stories into tasks Avoid the temptation of related changes All slides copyright 2000-2005, Mountain Goat Software59Slides copyright 2000-2004, Michael W. CohnTestable 60Tests demonstrate that a story meets thecustomer’s expectationsStrive for 90 % automationA user must findthe software easyto use.As a novice user, I amable to completecommon workflowswithout training.A user mustnever have towait long for ascreen to appear.New screens appearwithin 2 seconds in95% of all cases.All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn30

Fixing stories1) Assess the stories you’ve written forfBay against the INVEST attributes.2) Rewrite those that are do not meetthese criteria.3) If you can’t figure out how to rewrite astory, save it for class bleSmallTestableAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. CohnAs an OEM procurement agent I want the ability to search for suppliers based on criteria placed in aninput interface. The results include the following functionality: I am able to select one or more suppliers from the list of suppliers inthe database against which to perform the query. I input certain criteria into an interface, query the database, andreceive results as to which suppliers meet the criteria. The results are shown in order from highest match to lowest matchwith a symbol to show complete match of required criteria and a barto show overall match. The list should be paginated and have acertain discrete number of returns per page, with next/previous typenavigation. The query should be performed on the Business Factors: Type ofBusiness, Location, and Supplier Size. The query should be performed on technical factors: material,machine type, size, swing, axis.62All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn31

Today’s agenda Whatuser stories are Users and user roles Gathering stories INVEST in good stories Why user stories?All slides copyright 2000-2005, Mountain Goat Software66Slides copyright 2000-2004, Michael W. CohnSo, why user stories? Shift emphasis from writing to talkingIf requirementsare written downthenThe user will getwhat she wantsAt best, she’ll getwhat was written 67“You built what I asked for, but it’s notwhat I need.”All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn32

Actual examplesThe user can enter aname. It can be 127characters. Must the user enter aname? Can it be other than 127chars?The system shouldprominently display awarning messagewhenever the userenters invalid data. What does should mean? What does prominentlydisplay mean? Is invalid data definedelsewhere?All slides copyright 2000-2005, Mountain Goat Software68Slides copyright 2000-2004, Michael W. CohnAdditional reasons Stories are comprehensible Developersand customers understand them People are better able to remember events ifthey are organized into stories†Stories are the right size for planning Support and encourage iterativedevelopment Caneasily start with epics and disaggregatecloser to development time†Bow er, Black, and Turner. 1979.Scripts in Memory for Text.69All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn33

Yet more reasons Stories support opportunistic development Wedesign solutions by moving opportunisticallybetween top-down and bottom-up approaches† Stories support participatory design Participatory The users of the system become part of the team designingthe behavior of the system Empirical designdesignDesigners of the new system make decisions by studyingprospective users in typical situations†Guindon. 1990. Designingthe Design Process.70All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. CohnMost importantly Don’t forget thepurpose The story text we write on cards is lessimportant than the conversations wehave. “Stories represent requirements, theydo not document them.”††Rachel Davies, “The Pow er of Stories,” XP 2001.71All slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn34

Mike Cohn contact information 72mike@mountaingoatsoftware.com(303) 810–2190 (mobile)(720) 890–6110 (office)www.mountaingoatsoftware.comAll slides copyright 2000-2005, Mountain Goat SoftwareSlides copyright 2000-2004, Michael W. Cohn35

Writing Effective User Stories for Agile Requirements Mike Cohn September 26, 2005 . Programming for 20 years Author of User Stories Applied Agile Estimating and Planning Java, C , database programming books Founding member and director of the Agile Alliance and the . Mountain Goat Software 12 User roles Broaden the scope from looking at .