Extreme Programming XP

Document Sample
Extreme Programming XP Powered By Docstoc
					G51PRG-Sem2




   Extreme Programming
            XP
              Dave Elliman
G51PRG-Sem2
 With acknowledgments
          to:
William C. Wake

Ron Jefferies

Kent Beck




07/04/2010        Extreme Programming   2
G51PRG-Sem2

 Things that don’t work!
• The BIG specification first
• Exemplified by SSADM and
  Quality Systems in the UK
• Loved by students – why?
• It puts off the evil coding day?
• Specification will be wrong and
  so big you will lose heart!
07/04/2010    Extreme Programming   3
G51PRG-Sem2

 Things that don’t work!
• Starting with code and no
  design at all
• The the monkey-at-typewriter
  approach to making it work
• If you don’t have a clear model
  in you mind of how it works
  then it won’t!

07/04/2010    Extreme Programming   4
G51PRG-Sem2

  What does work then?
• Simplicity
    – (Proceed in incremental steps)
• Hiding complexity
• Separation of concerns
    – (Think about one thing at a time)
• Elegance and Pride in you work
• Formal models
    – (Think with mathematical precision)

07/04/2010        Extreme Programming       5
G51PRG-Sem2

Even then it won’t work
• You have to:
• TEST
• TEST
• TEST
• TEST
• TEST
• TEST it…
07/04/2010    Extreme Programming   6
G51PRG-Sem2

              XP is a ...
• A great man once said, “My
  yoke is easy and my burden is
  light”
• Had he been a software
  engineer, he might have been
  talking about XP…
• A lightweight, people-friendly
  approach

07/04/2010     Extreme Programming   7
G51PRG-Sem2

                    XP has...
• Very Short Development Cycles
• Emphasis on Testing
        functionality                          cost




             time                             quality

      It is honest about these trade-offs
07/04/2010              Extreme Programming             8
G51PRG-Sem2
  Extreme Programming
         Values
       • Simplicity
             – above all…
       • Communication
             – between everyone concerned
       • Feedback
             – testing and customers
       • Courage
             – to refactor (testing framework
               helps)

07/04/2010            Extreme Programming       9
G51PRG-Sem2

         Pair Programming
• All production code is written with
  two people looking at one machine,
  with one keyboard and one mouse
• Strategy
    –   Spot typos…
    –   Will this work? Is there a better way?
    –   What might get broken?
    –   How can we make this simpler?


07/04/2010          Extreme Programming          10
G51PRG-Sem2

             XP uses…
• Short design-code cycles
• and (automated) Tests
    to
• Monitor Progress and suitability
• Minimise risk and make it explicit
• Catch problems early
• Allow evolution
07/04/2010    Extreme Programming   11
G51PRG-Sem2

             Cost of Change
• The old model




07/04/2010       Extreme Programming   12
G51PRG-Sem2

             Cost of Change
• The XP model – Is it Reality?




07/04/2010       Extreme Programming   13
G51PRG-Sem2
  How XP lowers cost of
        change
• Incremental Evolution and
  communication means design
  stays what is wanted
• Simplicity, clarity, courageous
  refactoring and communication
  lead to clean code
• Automated testing proves it
  still works

07/04/2010    Extreme Programming   14
G51PRG-Sem2

             Communication
• Regular contact with customer
• User stories
• Pair Programming – do it in
  pairs
• Unit Tests – make test cases
• Experiment – try it!

07/04/2010       Extreme Programming   15
G51PRG-Sem2

             Simplicity
• “What is the simplest thing
  that would be of use?”
• BUILD IT!
• What is the most useful single
  thing to add to that?
• ADD IT!


07/04/2010    Extreme Programming   16
G51PRG-Sem2
       Simplicity supports
         Communication
               Simplicity


      see clearly                     facilitates



              Communication
07/04/2010          Extreme Programming             17
G51PRG-Sem2

             Have Courage to
               • Fix it!
               • Junk it!
               • Try it!




07/04/2010         Extreme Programming   18
G51PRG-Sem2

     Refactoring Example

       while( no_matches < 20) {
             find_another_match();
       }
       
       Const int max_matches = 20;
       While(no_matches < max_matches) {


07/04/2010         Extreme Programming     19
G51PRG-Sem2

             XP Activities

              • Coding
              • Testing
              • Listening
              • Designing




07/04/2010      Extreme Programming   20
G51PRG-Sem2
             The XP Cycle
             (in the small)

              analysis                 Looks wrong
                                        but it isn’t!
                    test
                            code

                                       design

07/04/2010       Extreme Programming                    21
G51PRG-Sem2

             Small Releases
• Deliver useful software on a very
  short cycle
• Something useful sooner
• Rapid feedback
• Sense of accomplishment
• Reduced risk
• Customer confidence
• Adjusts constantly to requirements

07/04/2010       Extreme Programming   22
G51PRG-Sem2

              Testing
• Any program feature without
  an automatic test simply does
  not exist.
• Unit tests make confidence in
  the operation of the program
  part of the program.
• Functional tests do the same
  for customers.

07/04/2010    Extreme Programming   23
G51PRG-Sem2

 Continuous Integration
• Integrate and test after a few
  hours - a day at most.
• If a test fails - you broke it!




07/04/2010    Extreme Programming   24
G51PRG-Sem2
             Collective Code
               Ownership
 • Whoever finds a snake, kills it
 • Unit tests protect functionality
 • Collective Code Ownership,
   plus Refactoring drives reuse:
 • Enhance it
 • subclass it (extends)
 • use it
07/04/2010       Extreme Programming   25
G51PRG-Sem2

 What’s Hard about XP?
• Always doing the simplest
  thing
• Admitting you don’t know
• Collaborating
• Breaking down emotional walls
  about “ownership”


07/04/2010    Extreme Programming   26
G51PRG-Sem2

    From the XP website!




  http://www.extremeprogramming.org/

07/04/2010    Extreme Programming      27
G51PRG-Sem2

                 Tip!

      Do your Group
      and 3rd year
      projects this way!

07/04/2010    Extreme Programming   28
G51PRG-Sem2

             Planning Game
  • Collect “user stories” these are
    about things that the customer
    wants
       – Short – a few sentences at most
       – Simple “use cases”
       – How little is needed for it to be
        useful
       – What is the priority
       – Customer says these things

07/04/2010         Extreme Programming       29
G51PRG-Sem2

      Recommended Tool
• Card Index Software
    – remember CardFile on Windows
     95?
        • what happened to it? I liked it!
    – Fat Free Software to the rescue
        • Business Cards – shareware $or
         29.95



07/04/2010         Extreme Programming       30
G51PRG-Sem2
             Business Cards




07/04/2010      Extreme Programming   31
G51PRG-Sem2

  Let’s Take an Example
 I set a Coursework some years ago:



       www.happydate.com



07/04/2010       Extreme Programming   32
G51PRG-Sem2

       The Dating Agency

                                               Story 1

             A person registers with the agency by
                providing personal information,
             information,about the kind of person
              they are seeking, an alias to conceal
              Their true identity, and confidential
                         contact details.


07/04/2010              Extreme Programming              33
G51PRG-Sem2

       The Dating Agency

                                               Story 2



               A selection of matching clients is
                displayed, and an email may be
             sent to any one of them. A charge will
                    be made for this service.



07/04/2010              Extreme Programming              34
G51PRG-Sem2

       The Dating Agency

                                             Story 3



              In order to be able to send Email,
               A person must have “beans” to
             Send. These can be purchased using
                 a credit or debit card online.



07/04/2010            Extreme Programming              35
G51PRG-Sem2

 Useful Technique.. UML
• UML needs to be supported by
  state of the art tools or it slows
  and fossilizes progress
• Helps planning and discussion
  and produces documentation
• XP says scribble it on cigarette
  packets and throw it away!

07/04/2010    Extreme Programming   36
G51PRG-Sem2

             Or Poseidon
• www.gentleware.com
• Community edition is free…




07/04/2010     Extreme Programming   37
G51PRG-Sem2


             A Development
             Environment?
                            http://www.borland.com/


  or                        http://www.jetbrains.com/idea/



                             http://argouml.tigris.org/

07/04/2010       Extreme Programming                      38
G51PRG-Sem2

             Use Cases




07/04/2010    Extreme Programming   39
G51PRG-Sem2
 What is simplest useful
        System?
• Abandon charging?
    – Yes – to get an initial customer base
• What is simplest matching that
  might be acceptable?
    – Gender different
    – Age within 12 years or each other
    – Location within 80 km



07/04/2010        Extreme Programming         40
G51PRG-Sem2

    What are the Objects?
•   Agency
•   Punter
•   Match
•   How do I know this?




07/04/2010    Extreme Programming   41
G51PRG-Sem2
             The Punter Object




07/04/2010        Extreme Programming   42
G51PRG-Sem2
             The Match Object




07/04/2010       Extreme Programming   43
G51PRG-Sem2
             The Agency Object




07/04/2010        Extreme Programming   44
G51PRG-Sem2

             What is missing?
• Distance(postcode1, Postcode2)
    – can we buy it? If so what does it cost?
• Web page and screen design
    – minimalist?
• People cannot leave
    – timeout?
• How is the data held?
    – suggest text file at first then database

07/04/2010          Extreme Programming         45
G51PRG-Sem2

              Tests
• There are Functional Tests
• and Unit Tests
• We want to design the tests
  before we write the code.
• We want a test-suite that runs
  any time we like.


07/04/2010    Extreme Programming   46
G51PRG-Sem2

             Functional Tests
• Specified by the user
• Implemented by users,
  developers, and/or test team
• Automated
• Run at least daily
• Part of the specification

07/04/2010        Extreme Programming   47
G51PRG-Sem2

             Unit Tests
• Written by developers
• Written before and after coding
• Always run at 100%
• Support design, coding,
  refactoring, and quality.



07/04/2010     Extreme Programming   48
G51PRG-Sem2

      Recommended Tool

     http://www.junit.org

     A set of classes that enable a
     suite of acceptance tests to be
     built alongside code



07/04/2010        Extreme Programming   49
G51PRG-Sem2




 Register a Punter            Test
• get Email address           • is format valid?
                                Does it exist?
• Get Age                     • 0 >= age <= 112


• Get Postcode                • Is postcode valid?


• Create a key                • Is key unique?


07/04/2010       Extreme Programming             50
G51PRG-Sem2

         JUnit Test Runner




07/04/2010    Extreme Programming   51
G51PRG-Sem2
  More Info When a Test
          Fails




07/04/2010    Extreme Programming   52
G51PRG-Sem2

                 Test Metrics



                                               Key:
                                                Tests failed
                                                Tests passed



        1    2   3   4    5    6    7
07/04/2010               Extreme Programming                   53
G51PRG-Sem2

             XP is excellent if:
• You are in a world of rapid change
• You have uncertain requirements
• The project is small or medium sized
• BUT:
• For Very large products use SSADM or
  similar with XP for the parts
• For Safety-critical projects use Formal
  Methods as well as XP
07/04/2010         Extreme Programming   54

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:72
posted:4/7/2010
language:English
pages:54