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

Extreme Isolation Workshop

Extreme Isolation Workshop

Workshop given at Scottish Ruby Conference 2014. Some refactoring tools based around the ideas of Hexagonal Rails, the Actor Model of Concurrency, Immutability and functional programming.

chrismdp

May 13, 2014
Tweet

More Decks by chrismdp

Other Decks in Programming

Transcript

  1. EXTREME ISOLATION WORKSHOP @chrismdp Scottish Ruby Conference 2014

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

  3. I HAVE NO IDEA WHAT I’M DOING I just read

    other people’s blog posts and put them together
  4. IS TDD DEAD? @chrismdp

  5. None
  6. None
  7. PROBLEM

  8. 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
  9. HEXAGONAL RAILS Ports and Adaptors

  10. persistence web mailer view controller domain

  11. persistence web mailer view controller domain

  12. persistence web Plain Ruby representing your domain mailer

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

  14. LIVE CODING

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

  16. SO HOW WOULD WE TEST THIS? ! Would you use

    system tests? Would you use mocks? Would you test at all?
  17. ACTOR MODEL OF CONCURRENCY Separating Arrangement and Work

  18. baz bar foo quux eke

  19. bar test quux test foo test bar foo quux mock

    bar mock quuz mock bar
  20. 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
  21. LIVE CODING

  22. YOUR TURN

  23. domain persistence Person

  24. Person Repository Person PORO Mongo

  25. FROZEN OBJECTS

  26. Person Repository Person

  27. PersonRepository PersonValidator Person Web Handler Mongo web page request Request

    Handler InvalidPerson UpdatePerson
  28. LIVE CODING

  29. BENEFITS

  30. 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
  31. EACH OBJECT IS INDEPENDENT Dealing with value objects on the

    edges
  32. UpdatePerson Web Handler web page InvalidPerson

  33. PersonRepository UpdatePerson MySQL InvalidPerson

  34. IMMUTABLE VALUE OBJECTS Freeze is your friend

  35. DISADVANTAGES

  36. TEST DRIVEN DESIGN DAMAGE

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

  38. 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
  39. BLOG SERIES http://chrismdp.com

  40. THANKS @chrismdp