Slide 1

Slide 1 text

EXTREME ISOLATION WORKSHOP @chrismdp Scottish Ruby Conference 2014

Slide 2

Slide 2 text

http://github.com/chrismdp/spacemud extreme isolation - @chrismdp git clone git://github.com:chrismdp/spacemud.git

Slide 3

Slide 3 text

I HAVE NO IDEA WHAT I’M DOING I just read other people’s blog posts and put them together

Slide 4

Slide 4 text

IS TDD DEAD? @chrismdp

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

PROBLEM

Slide 8

Slide 8 text

baz bar foo quux eke baz bar foo quux eke baz bar foo quux eke baz bar foo quux eke baz bar foo quux eke foo quux baz bar foo quux eke baz bar eke bar foo quux baz eke bar foo quux

Slide 9

Slide 9 text

HEXAGONAL RAILS Ports and Adaptors

Slide 10

Slide 10 text

persistence web mailer view controller domain

Slide 11

Slide 11 text

persistence web mailer view controller domain

Slide 12

Slide 12 text

persistence web Plain Ruby representing your domain mailer

Slide 13

Slide 13 text

SPACE MUD http://github.com/chrismdp/spacemud

Slide 14

Slide 14 text

LIVE CODING

Slide 15

Slide 15 text

YOUR TURN http://github.com/chrismdp/spacemud

Slide 16

Slide 16 text

SO HOW WOULD WE TEST THIS? ! Would you use system tests? Would you use mocks? Would you test at all?

Slide 17

Slide 17 text

ACTOR MODEL OF CONCURRENCY Separating Arrangement and Work

Slide 18

Slide 18 text

baz bar foo quux eke

Slide 19

Slide 19 text

bar test quux test foo test bar foo quux mock bar mock quuz mock bar

Slide 20

Slide 20 text

bar foo POROs baz calling code handles the arrangement ! objects handle the work, don’t know about others ! objects can be called in any order POROs POROs

Slide 21

Slide 21 text

LIVE CODING

Slide 22

Slide 22 text

YOUR TURN

Slide 23

Slide 23 text

domain persistence Person

Slide 24

Slide 24 text

Person Repository Person PORO Mongo

Slide 25

Slide 25 text

FROZEN OBJECTS

Slide 26

Slide 26 text

Person Repository Person

Slide 27

Slide 27 text

PersonRepository PersonValidator Person Web Handler Mongo web page request Request Handler InvalidPerson UpdatePerson

Slide 28

Slide 28 text

LIVE CODING

Slide 29

Slide 29 text

BENEFITS

Slide 30

Slide 30 text

Database (AR) Database (BerkeleyDB) CHANGEABILITY Drop in new adaptor implementation at the edges POROs calling code handles the arrangement ! objects handle the work, don’t know about others ! objects can be called in any order POROs Web (Rails) Web (Sinatra) Web Sockets

Slide 31

Slide 31 text

EACH OBJECT IS INDEPENDENT Dealing with value objects on the edges

Slide 32

Slide 32 text

UpdatePerson Web Handler web page InvalidPerson

Slide 33

Slide 33 text

PersonRepository UpdatePerson MySQL InvalidPerson

Slide 34

Slide 34 text

IMMUTABLE VALUE OBJECTS Freeze is your friend

Slide 35

Slide 35 text

DISADVANTAGES

Slide 36

Slide 36 text

TEST DRIVEN DESIGN DAMAGE

Slide 37

Slide 37 text

FURTHER EXAMPLE ON GITHUB http://github.com/thinkcodelearn/discover

Slide 38

Slide 38 text

SANDI METZ’S PRACTICAL OBJECT ORIENTED DESIGN LONDON 3 day course 25-27 June // 2 day course: 2-3 July 5% off! Use code SCO TRUBY http://kickstartacademy.io

Slide 39

Slide 39 text

BLOG SERIES http://chrismdp.com

Slide 40

Slide 40 text

THANKS @chrismdp