Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

@bkeepers I

Slide 4

Slide 4 text

opensoul.org I

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

group therapy

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

pride

Slide 10

Slide 10 text

craftsman

Slide 11

Slide 11 text

art

Slide 12

Slide 12 text

I

Slide 13

Slide 13 text

get.harmonyapp.com

Slide 14

Slide 14 text

get.gaug.es

Slide 15

Slide 15 text

speakerdeck.com

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

I — GOOD CODE!

Slide 18

Slide 18 text

not perfect

Slide 19

Slide 19 text

:(

Slide 20

Slide 20 text

HAS NOT IMPLODED

Slide 21

Slide 21 text

HAS NOT IMPLODED yet ^

Slide 22

Slide 22 text

RUNS

Slide 23

Slide 23 text

in spite of

Slide 24

Slide 24 text

because of

Slide 25

Slide 25 text

bad software

Slide 26

Slide 26 text

pragmatism perfection

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

good software

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

adequacy

Slide 31

Slide 31 text

!mediocrity

Slide 32

Slide 32 text

objective

Slide 33

Slide 33 text

software != code

Slide 34

Slide 34 text

“ 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.

Slide 35

Slide 35 text

users don’t care

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

cost

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

Production almost zero of

Slide 40

Slide 40 text

$$$$

Slide 41

Slide 41 text

$$$

Slide 42

Slide 42 text

$$

Slide 43

Slide 43 text

$

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

risk

Slide 46

Slide 46 text

!science

Slide 47

Slide 47 text

‑Risk ‐Cost

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

entropy

Slide 50

Slide 50 text

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

Slide 51

Slide 51 text

why?

Slide 52

Slide 52 text

software is malleable

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

software is complex

Slide 55

Slide 55 text

rake stats

Slide 56

Slide 56 text

2.5 million parts

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

software is immature

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

software is opaque

Slide 61

Slide 61 text

software is durable

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

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

Slide 64

Slide 64 text

better software? how do we build

Slide 65

Slide 65 text

talk to your users

Slide 66

Slide 66 text

automated testing

Slide 67

Slide 67 text

insurance policy

Slide 68

Slide 68 text

automation computers are good at

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

DRY

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

refactoring small, incremental

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

Examples

Slide 75

Slide 75 text

method_missing

Slide 76

Slide 76 text

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

Slide 77

Slide 77 text

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

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

performance maintenance

Slide 80

Slide 80 text

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} #{moves_count} #{random_seed}

Slide 81

Slide 81 text

#{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} #{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

Slide 82

Slide 82 text

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

Slide 83

Slide 83 text

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

Slide 84

Slide 84 text

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

Slide 85

Slide 85 text

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

Slide 86

Slide 86 text

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

Slide 87

Slide 87 text

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'

Slide 88

Slide 88 text

now what?

Slide 89

Slide 89 text

pragmatic

Slide 90

Slide 90 text

software is design

Slide 91

Slide 91 text

embrace constraints

Slide 92

Slide 92 text

engineering is design

Slide 93

Slide 93 text

craftsmanship is design

Slide 94

Slide 94 text

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

Slide 95

Slide 95 text

opportunity costs

Slide 96

Slide 96 text

be pragmatic

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

“ 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.

Slide 99

Slide 99 text

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

Slide 100

Slide 100 text

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/