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

Following the ERD: How to Map Your Software

F4d5752d6f4f839083cf810ad2c3a911?s=47 Kerri Miller
September 15, 2018

Following the ERD: How to Map Your Software

F4d5752d6f4f839083cf810ad2c3a911?s=128

Kerri Miller

September 15, 2018
Tweet

Transcript

  1. [TITLE PENDING] Double-click to edit @kerrizor CodeDaze 2018

  2. [TITLE PENDING] Double-click to edit @kerrizor CodeDaze 2018

  3. @kerrizor CodeDaze 2018

  4. @kerrizor CodeDaze 2018

  5. @kerrizor CodeDaze 2018

  6. @kerrizor CodeDaze 2018 @kerrizor CodeDaze 2018

  7. @kerrizor CodeDaze 2018

  8. @kerrizor CodeDaze 2018

  9. @kerrizor CodeDaze 2018 42/50 Stamps, 20/25 States

  10. @kerrizor CodeDaze 2018

  11. @kerrizor CodeDaze 2018

  12. @kerrizor CodeDaze 2018

  13. @kerrizor CodeDaze 2018

  14. @kerrizor CodeDaze 2018

  15. @kerrizor CodeDaze 2018 graph graphname { a -- b --

    c; b -- d; }
  16. @kerrizor CodeDaze 2018

  17. @kerrizor CodeDaze 2018 digraph graphname { a -> b ->

    c; b -> d; }
  18. @kerrizor CodeDaze 2018

  19. digraph G { subgraph cluster_0 { style=filled; color=lightgrey; node [style=filled,color=white];

    a0 -> a1 -> a2 -> a3; label = "process #1"; } subgraph cluster_1 { node [style=filled]; b0 -> b1 -> b2 -> b3; label = "process #2"; color=blue } start -> a0; start -> b0; a1 -> b3; b2 -> a3; a3 -> a0; a3 -> end; b3 -> end; start [shape=Mdiamond]; end [shape=Msquare]; } @kerrizor CodeDaze 2018
  20. @kerrizor CodeDaze 2018

  21. @kerrizor CodeDaze 2018

  22. @kerrizor CodeDaze 2018

  23. @kerrizor CodeDaze 2018

  24. @kerrizor CodeDaze 2018

  25. @kerrizor CodeDaze 2018 E X T R A C T

    I N G M O D E L R E L AT I O N S H I P S • Ask the DB/Parse the schema • Parse model definitions in the framework
  26. @kerrizor CodeDaze 2018 E X T R A C T

    I N G M O D E L R E L AT I O N S H I P S • Ask the DB/Parse the schema • Parse model definitions in the framework
  27. @kerrizor CodeDaze 2018 E X T R A C T

    I N G M O D E L R E L AT I O N S H I P S • Ask the DB/Parse the schema • Parse model definitions in the framework • Have the framework introspect for you
  28. @kerrizor CodeDaze 2018 g = GraphViz.new(:G, type: :digraph) models =

    ActiveRecord::Base.descendants assoc = models.first.reflect_on_all_associations.collect{|r| r.klass.to_s.downcase}.uniq # Raise your left hand if you’re reading this # user = g.add_nodes("User") assoc.each do |a| g.add_edges(user, g.add_nodes(a)) end g.output(png: "example.png")
  29. @kerrizor CodeDaze 2018

  30. @kerrizor CodeDaze 2018 digraph G { graph [bb="0,0,362.83,108"]; node [label="\N"];

    user [height=0.5, label=user, pos="177.66,90", width=0.75]; Article [height=0.5, label=Article, pos="34.66,18", width=0.96276]; user -> Article [pos="e,59.965,30.741 155.94,79.065 132.88,67.452 96.092,48.931 69.076,35.328"]; Favorite [height=0.5, label=Favorite, pos="126.66,18", width=1.0994]; user -> Favorite [pos="e,138.9,35.277 166.09,73.662 159.81,64.805 151.92,53.658 144.84,43.67"]; […]
  31. @kerrizor CodeDaze 2018 g = GraphViz.new(:G, type: :digraph) models =

    ActiveRecord::Base.descendants assoc = models.first.reflect_on_all_associations.collect{|r| r.klass.to_s.downcase}.uniq user = g.add_nodes("User") assoc.each do |a| attrs = a.classify.constantize.attribute_names label = "#{a}\n#{attrs.join("\n")}" g.add_edges(user, g.add_nodes(label)) end g.output(png: "example_with_labels.png")
  32. @kerrizor CodeDaze 2018

  33. @kerrizor CodeDaze 2018

  34. @kerrizor CodeDaze 2018 https://github.com/voormedia/rails-erd

  35. @kerrizor CodeDaze 2018 $ bundle viz

  36. @kerrizor CodeDaze 2018

  37. @kerrizor CodeDaze 2018

  38. @kerrizor CodeDaze 2018

  39. @kerrizor CodeDaze 2018

  40. @kerrizor CodeDaze 2018

  41. @kerrizor CodeDaze 2018

  42. @kerrizor CodeDaze 2018

  43. @kerrizor CodeDaze 2018

  44. @kerrizor CodeDaze 2018

  45. @kerrizor CodeDaze 2018

  46. @kerrizor CodeDaze 2018 “ ” THE MAP IS NOT THE

    TERRITORY… THE WORD IS NOT THE THING… - ALFRED KORZYBSKI M A P - T E R R I T O RY R E L AT I O N
  47. @kerrizor CodeDaze 2018

  48. @kerrizor CodeDaze 2018

  49. @kerrizor CodeDaze 2018

  50. @kerrizor CodeDaze 2018

  51. @kerrizor CodeDaze 2018

  52. @kerrizor CodeDaze 2018 A N D I F Y O

    U A C T N O W… • Visual documentation for GraphQL • Shortcut for loading context • “Living Documentation”
  53. @kerrizor CodeDaze 2018 “ ” WHEN YOU CHANGE THE WAY

    YOU LOOK AT THINGS, THE THINGS YOU LOOK AT CHANGE. - DR WAYNE W DYER M A P - T E R R I T O RY R E L AT I O N
  54. @kerrizor CodeDaze 2018 M A P - T E R

    R I T O RY R E L AT I O N
  55. @kerrizor CodeDaze 2018 kerrizor@kerrizor.com

  56. @kerrizor CodeDaze 2018 MOTOZOR.COM