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

The World Runs on Bad Software

The World Runs on Bad Software

Brandon Keepers
PRO

August 12, 2011
Tweet

More Decks by Brandon Keepers

Other Decks in Programming

Transcript

  1. Brandon Keepers
    Lone Star Ruby Conference V
    August 12, 2011
    BAD
    the world runs on
    software
    Ordered List

    View Slide

  2. View Slide

  3. @bkeepers
    I

    View Slide

  4. opensoul.org
    I

    View Slide

  5. View Slide

  6. group therapy

    View Slide

  7. View Slide

  8. View Slide

  9. pride

    View Slide

  10. craftsman

    View Slide

  11. art

    View Slide

  12. I

    View Slide

  13. get.harmonyapp.com

    View Slide

  14. get.gaug.es

    View Slide

  15. speakerdeck.com

    View Slide

  16. View Slide

  17. I — GOOD CODE!

    View Slide

  18. not perfect

    View Slide

  19. :(

    View Slide

  20. HAS NOT
    IMPLODED

    View Slide

  21. HAS NOT
    IMPLODED yet
    ^

    View Slide

  22. RUNS

    View Slide

  23. in spite of

    View Slide

  24. because of

    View Slide

  25. bad software

    View Slide

  26. pragmatism
    perfection

    View Slide

  27. What is good software?
    How does it go bad?
    How do we build better software?

    View Slide

  28. good software

    View Slide


  29. Good software meets the
    present objective at an
    acceptable cost without
    incurring an unacceptable
    amount of future risk.

    View Slide

  30. adequacy

    View Slide

  31. !mediocrity

    View Slide

  32. objective

    View Slide

  33. software
    !=
    code

    View Slide


  34. Zach Dennis
    Mutually Human Software
    People fail to realize that
    quality is merely a property of
    the code that exists, not the
    reason for its existence.

    View Slide

  35. users don’t care

    View Slide


  36. Scott Berkun
    We’re frustrated most in
    life by things that come
    close to our deepest
    needs, but don’t deliver.

    View Slide

  37. cost

    View Slide


  38. Ray Yeargin
    Virtually all of the cost of
    software development is,
    directly and indirectly, the
    cost of design.

    View Slide

  39. Production
    almost zero of

    View Slide

  40. $$$$

    View Slide

  41. $$$

    View Slide

  42. $$

    View Slide

  43. $

    View Slide

  44. View Slide

  45. risk

    View Slide

  46. !science

    View Slide

  47. ‑Risk
    ‐Cost

    View Slide

  48. What is good software?
    How does it go bad?
    How do we build better software?

    View Slide

  49. entropy

    View Slide


  50. The Pragmatic Programmer
    While software development
    is immune from almost all
    physical laws, entropy hits
    us hard.

    View Slide

  51. why?

    View Slide

  52. software is
    malleable

    View Slide

  53. View Slide

  54. software is
    complex

    View Slide

  55. rake stats

    View Slide

  56. 2.5 million parts

    View Slide

  57. View Slide

  58. software is
    immature

    View Slide

  59. View Slide

  60. software is
    opaque

    View Slide

  61. software is
    durable

    View Slide

  62. View Slide

  63. What is good software?
    How does it go bad?
    How do we build better software?

    View Slide

  64. better software?
    how do we build

    View Slide

  65. talk to your users

    View Slide

  66. automated testing

    View Slide

  67. insurance policy

    View Slide

  68. automation
    computers are good at

    View Slide

  69. View Slide

  70. DRY

    View Slide

  71. View Slide

  72. refactoring
    small, incremental

    View Slide

  73. What is good software?
    How does it go bad?
    How do we build better software?

    View Slide

  74. Examples

    View Slide

  75. method_missing

    View Slide

  76. class NilClass
    def method_missing(method, *args)
    nil
    end
    end

    View Slide

  77. >> nil.foo.bar
    => nil
    >> nil + 5
    => nil
    >> 5 + nil
    TypeError: coerce must return [x, y]

    View Slide

  78. View Slide

  79. performance
    maintenance

    View Slide

  80. def to_xml(options={})
    root_tag = options.fetch(:root, 'game')
    instruct = options[:skip_instruct] ? '' : XML_INSTRUCT
    # …
    # gather up a bunch of variables
    # …
    <<-EOF
    #{instruct}
    <#{root_tag}>
    #{id}
    #{current_move_user_id}
    current-move-user-id>
    #{created_by_user_id}
    created-by-user-id>
    0
    #{is_matchmaking}
    #{was_matchmaking}matchmaking>
    #{moves_count}
    #{random_seed}

    View Slide

  81. #{instruct}
    <#{root_tag}>
    #{id}
    #{current_move_user_id}
    current-move-user-id>
    #{created_by_user_id}
    created-by-user-id>
    0
    #{is_matchmaking}
    #{was_matchmaking}matchmaking>
    #{moves_count}
    #{random_seed}
    #{client_version}
    #{created_at.try(:xmlschema)}
    created-at>
    #{users_xml}
    #{current_user_xml}
    #{moves_xml}
    #{chats_xml}
    #{root_tag}>
    EOF
    end

    View Slide

  82. commit fa779d9c2d1214e43ff497f386b51ebf3708346e
    Author: Brandon Keepers
    Date: Wed Sep 22 17:08:38 2010 -0400
    First attempt at getting embedded callbacks working

    View Slide

  83. def create_or_update
    run_callbacks(:before_save)
    if result = super
    run_callbacks(:after_save)
    end
    result
    end
    Rails 2

    View Slide

  84. def create_or_update
    run_callbacks(:save) { super }
    end
    Rails 3

    View Slide

  85. def run_callbacks(kind, options={}, &block)
    self.embedded_associations.each do |association|
    self.send(association.name).run_callbacks(
    kind, options, &block
    )
    end
    end

    View Slide

  86. def run_callbacks(callback, &block)
    embedded_docs = []
    embedded_associations.each do |association|
    embedded_docs += association.target
    end
    block = embedded_docs.inject(block) do |chain, doc|
    if doc.class.respond_to?("_#{callback}_callbacks")
    lambda { doc.run_callbacks(callback, &chain) }
    else
    chain
    end
    end
    super callback, &block
    end

    View Slide

  87. SystemStackError: stack level too deep
    from mongo_mapper/plugins/embedded_callbacks.rb:23:in `run_callbacks'
    from activesupport-3.0.9/lib/active_support/callbacks.rb:414:in
    `_run_create_callbacks'
    from activesupport-3.0.9/lib/active_support/callbacks.rb:94:in `send'
    from activesupport-3.0.9/lib/active_support/callbacks.rb:94:in
    `run_callbacks'
    from mongo_mapper/plugins/embedded_callbacks.rb:28:in `run_callbacks'
    from mongo_mapper/plugins/embedded_callbacks.rb:23:in `run_callbacks'

    View Slide

  88. now what?

    View Slide

  89. pragmatic

    View Slide

  90. software is design

    View Slide

  91. embrace constraints

    View Slide

  92. engineering is design

    View Slide

  93. craftsmanship is design

    View Slide


  94. Glen Vanderburg
    Sometimes you have to move
    ahead with weak evidence and
    weak conclusions because you
    don't have time to prove them.

    View Slide

  95. opportunity costs

    View Slide

  96. be pragmatic

    View Slide

  97. View Slide


  98. Ed Yourdon
    You can discipline yourself to write
    software that's good enough—good
    enough for your users, for future
    maintainers, for your own peace of
    mind. You'll find that you are more
    productive and your users are happier.

    View Slide

  99. Ordered List
    Thank you!
    [email protected]
    Brandon Keepers
    Lone Star Ruby Conference V
    August 12, 2011
    @bkeepers
    http://spkr8.com/t/7829

    View Slide

  100. Credits
    Power lines - http://www.flickr.com/photos/viamoi/3339707547/
    House of cards - http://www.flickr.com/photos/gibbons/2294374741/
    Dentists office - http://www.flickr.com/photos/cmdrcord/4996672560/
    Broken chair - http://www.flickr.com/photos/gorbould/3004789912/
    Schematics - http://www.flickr.com/photos/nicklockey/4547935355/
    Engineers - http://www.flickr.com/photos/seattlemunicipalarchives/4818952324/
    Black box - http://goldberg.berkeley.edu/art/big-images/

    View Slide