Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Divide & Conquer: An Iterative Approach To Writ...

Divide & Conquer: An Iterative Approach To Writing Software

Presentation to a group of high school computer science teachers about how to break down software problems.

Mark Crossfield

July 11, 2018
Tweet

More Decks by Mark Crossfield

Other Decks in Technology

Transcript

  1. Divide & Conquer: An Iterative Approach To Writing Software Mark

    Crossfield, July 2018 whose pronoun.is/he
  2. 3

  3. Requirements • Users must supply a username and a password

    to authenticate • Their username and password must be checked against the database table of known users • If the username is found and the password matches then they must be authenticated • If the username is not found then the user must not be authenticated • If the user is found but the password does not match then the user must not be authenticated 4
  4. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘sesame’ Then the user is authenticated
  5. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘letmein’ Then the user is not authenticated
  6. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  7. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  8. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  9. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  10. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘sesame’ Then the user is authenticated
  11. 32

  12. 33

  13. Don’t jump ahead, call code before you define it, so

    that you know what it needs to do
  14. 36

  15. 37

  16. 38

  17. 39

  18. 40

  19. 42

  20. 43

  21. 44

  22. 45

  23. 46

  24. 47

  25. 48

  26. 49

  27. 50

  28. 51

  29. 52

  30. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘sesame’ Then the user is authenticated
  31. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  32. 55

  33. 56

  34. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  35. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘sesame’ Then the user is authenticated
  36. 59

  37. 60

  38. 61

  39. 62

  40. 63

  41. 64

  42. 65

  43. 66

  44. 67

  45. 68

  46. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘sesame’ Then the user is authenticated
  47. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  48. 71

  49. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘mark’ and password ‘sesame’ Then the user is not authenticated
  50. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘letmein’ Then the user is not authenticated
  51. 74

  52. Given a user exists with username ‘james’ and password ‘sesame’

    When a user logs in with username ‘james’ and password ‘letmein’ Then the user is not authenticated
  53. Summary Shorten Feedback Loops Start with the smallest thing… cheat

    if necessary Work from the outside towards the happy path Do one thing at once Fake things Call code before writing it Test all the time Practice your practices! 76
  54. Learning Resources Structured exercises—work locally • http://exercism.io/ Structured exercises you

    can do in the browser • https://www.hackerrank.com/ • http://www.codewars.com/ Generic problems you can try to solve in any language • http://codingdojo.org/kata/ • Book: 57 Challenges to Develop Your Coding Skills https://pragprog.com/book/bhwb/exercises-for-programmers 77