Slide 1

Slide 1 text

The Insufficiency of Good Design Sarah Mei Pivotal Labs

Slide 2

Slide 2 text

http://www.flickr.com/photos/vblibrary/5740555555

Slide 3

Slide 3 text

The Insufficiency of Good Design Sarah Mei Pivotal Labs

Slide 4

Slide 4 text

Good Code

Slide 5

Slide 5 text

http://www.flickr.com/photos/uggboy/4065592853

Slide 6

Slide 6 text

Write More Good Code Sarah Mei Pivotal Labs

Slide 7

Slide 7 text

http://www.flickr.com/photos/katerha/7071545621

Slide 8

Slide 8 text

class StuffController def show @stuff = Stuff.find(params[:id] end end

Slide 9

Slide 9 text

class StuffController def show @stuff = Stuff.find(params[:id] end end

Slide 10

Slide 10 text

class StuffController def show @stuff = Stuff.find(params[:id] end end

Slide 11

Slide 11 text

Thing C B A Z Y X

Slide 12

Slide 12 text

http://www.flickr.com/photos/ell-r-brown/5808881905

Slide 13

Slide 13 text

ActiveRecord ::Base C B A Z Y X

Slide 14

Slide 14 text

C B A Z Y X The PM has not decided exactly what this part of our app actually does.

Slide 15

Slide 15 text

Good code is defined by its pattern of dependencies

Slide 16

Slide 16 text

Good Code

Slide 17

Slide 17 text

Good Code 1. OO design principles

Slide 18

Slide 18 text

Law of Demeter @stuff

Slide 19

Slide 19 text

Law of Demeter @stuff @stuff.things OK

Slide 20

Slide 20 text

Law of Demeter @stuff @stuff.things OK @stuff.things.foo.bar OK?

Slide 21

Slide 21 text

Good Code 1. OO design principles

Slide 22

Slide 22 text

Good Code 1. OO design principles

Slide 23

Slide 23 text

Good Code 1. OO design principles 2. Development practices

Slide 24

Slide 24 text

Good Code 1. OO design principles 2. Development practices 3.

Slide 25

Slide 25 text

Good Code 1. OO design principles Other People 2. Development practices 3.

Slide 26

Slide 26 text

Person Person Person Person Person Person Person

Slide 27

Slide 27 text

Person Person Person Person Person Person Person

Slide 28

Slide 28 text

Person Person Person Person Person Person Person

Slide 29

Slide 29 text

The aspects of things that are most important to us are hidden because of their simplicity and familiarity. Wittgenstein

Slide 30

Slide 30 text

http://www.flickr.com/photos/0742/2912757295

Slide 31

Slide 31 text

http://www.flickr.com/photos/63085612@N00/111068688

Slide 32

Slide 32 text

Any organization that designs a system will inevitably produce a design whose structure is a copy of the organization's communication structure. Text of paper: http://bit.ly/RrHWvp

Slide 33

Slide 33 text

If you have four groups working on a compiler, you’ll get a four-pass compiler.

Slide 34

Slide 34 text

http://www.flickr.com/photos/itchmo/421586877 http://www.flickr.com/photos/itchmo/421586868/

Slide 35

Slide 35 text

Army Team Navy Team Coordinators Team structure

Slide 36

Slide 36 text

Army Team Navy Team Coordinators Team structure Army Specific Navy Specific Common functions Resulting software

Slide 37

Slide 37 text

http://www.flickr.com/photos/pagedooley/1092862034 http://www.flickr.com/photos/wjlonien/6289588338

Slide 38

Slide 38 text

http://www.jimloy.com/games/freecell.htm FreeCell Game #11982

Slide 39

Slide 39 text

http://www.cc2e.com

Slide 40

Slide 40 text

http://www.cc2e.com OK

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

http://www.flickr.com/photos/wrote/2247307130

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

H E G C B A D F

Slide 46

Slide 46 text

H E G C B A D F

Slide 47

Slide 47 text

H E G C B A D F Ruby Haskell PHP Java R Python C Hadoop

Slide 48

Slide 48 text

http://www.flickr.com/photos/proimos/4199675334

Slide 49

Slide 49 text

Good Code Predictors

Slide 50

Slide 50 text

Good Code Predictors • Technical qualifications

Slide 51

Slide 51 text

Good Code Predictors • Technical qualifications • Experience with the code base

Slide 52

Slide 52 text

Good Code Predictors • Technical qualifications • Experience with the code base • Good communication

Slide 53

Slide 53 text

Your team’s communication patterns are the best predictor of the quality of the code you produce. 1

Slide 54

Slide 54 text

http://www.flickr.com/photos/fsse-info/4320090112

Slide 55

Slide 55 text

http://www.flickr.com/photos/tyrian123/2131287203/

Slide 56

Slide 56 text

http://www.flickr.com/photos/puuikibeach/4396269637

Slide 57

Slide 57 text

class Stuff < ActiveRecord::Base include Rails.app.url_helpers def as_json {url: stuff_url(id)} end end

Slide 58

Slide 58 text

class Stuff < ActiveRecord::Base include Rails.app.url_helpers def as_json {url: stuff_url(id)} end end

Slide 59

Slide 59 text

class Stuff < ActiveRecord::Base include Rails.app.url_helpers def as_json {url: stuff_url(id)} end end

Slide 60

Slide 60 text

class Stuff < ActiveRecord::Base end class StuffPresenter < Presenter def as_json {url: stuff_url(id)} end end

Slide 61

Slide 61 text

class Stuff < ActiveRecord::Base include Rails.app.url_helpers def as_json {url: stuff_url(id)} end end

Slide 62

Slide 62 text

class StuffController < AppContro def show render json: @stuff.as_json.merge({ url: stuff_url(@stuff) }) end end

Slide 63

Slide 63 text

Skinny controllers, fat models

Slide 64

Slide 64 text

Skinny controllers, fat models Skinny controllers, models that only have code related to their main purpose: persistance. Move other stuff out to non- ActiveRecord classes.

Slide 65

Slide 65 text

Decoding Smelly Code

Slide 66

Slide 66 text

Decoding Smelly Code 1. Hidden silo

Slide 67

Slide 67 text

Decoding Smelly Code 1. Hidden silo 2. Developers ready for more nuance

Slide 68

Slide 68 text

Decoding Smelly Code 1. Hidden silo 2. Developers ready for more nuance 2.1. Developers actually listen to me o.0

Slide 69

Slide 69 text

Every piece of bad code is trying to tell you something. 2

Slide 70

Slide 70 text

Fixing Problems

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

http://www.flickr.com/photos/juniorvelo/4490511204

Slide 73

Slide 73 text

Fixing Problems • Pair programming

Slide 74

Slide 74 text

Create opportunities for informal communication

Slide 75

Slide 75 text

Use High-Bandwidth Communication http://www.flickr.com/photos/beglendc/434086133

Slide 76

Slide 76 text

http://www.flickr.com/photos/malias/73169727

Slide 77

Slide 77 text

Fixing Problems • Pair programming • Create opportunities for informal communication • Use high-bandwidth communication • Teach/learn/practice

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

Hack your team 3

Slide 80

Slide 80 text

• Think about team dynamics • Use code smells to illuminate problems • Fix them! http://www.flickr.com/photos/uggboy/4066337480

Slide 81

Slide 81 text

• Think about team dynamics • Use code smells to illuminate problems • Fix them! http://www.flickr.com/photos/uggboy/4066337480

Slide 82

Slide 82 text

Thank you! Sarah Mei Pivotal Labs @sarahmei [email protected]