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

Structural Engineering in Ruby

Affa5b7b3a311fcf5f868859d586b410?s=47 shagemann
January 31, 2020

Structural Engineering in Ruby

Morning keynote at Birmingham on Rails in Birmingham, AL in January 31, 2020

https://birminghamonrails.com/

Affa5b7b3a311fcf5f868859d586b410?s=128

shagemann

January 31, 2020
Tweet

Transcript

  1. None
  2. Village

  3. Open landscape

  4. Street

  5. City

  6. City

  7. Crumbling street

  8. Building maintenance

  9. Big or Small? Stand up if in your codebase you…

    • have more than 50 models • have a class with more than a 1000 LOC • have an ActiveRecord model with more than 30 :has_many • can’t run your full test suite on your machine • can’t run your test suite on your machine in under 20 minutes
  10. Street

  11. Structural Engineering in Ruby Stephan Hagemann

  12. None
  13. The only thing that ultimately let’s you reign in complexity

    within one app are components
  14. As a language, Ruby does not have components

  15. Gems can act as components

  16. …they work well

  17. For Rails, the situation kinda sucks…

  18. …but works ok

  19. Let’s make it better!

  20. None
  21. None
  22. None
  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. None
  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. None
  37. None
  38. None
  39. Just a normal Rails app
 with some extra structure…

  40. None
  41. None
  42. Structural 
 Costs + Benefits

  43. None
  44. Method 2 LOC Costs Hide logic Benefits Allow Reuse

  45. Class 2 LOC Costs Bundle logic and data Benefits Allow

    Reuse
  46. Namespace 2 LOC Costs Prevent naming collisions in the global

    namespace Benefits Group 
 classes 
 and methods
  47. Component

  48. WHAT IS A COMPONENT?

  49. Labeled Content + Explicit Dependencies

  50. Labeled, Unique Content + Explicit, Directed, Acyclic Dependencies

  51. @shageman cbra.info ?

  52. @shageman cbra.info

  53. @shageman cbra.info ? ?

  54. Labeled, Unique Content + Explicit, Directed, Acyclic Dependencies

  55. @shageman cbra.info

  56. A depends on B … A B

  57. thus B can not depend on A A B X

  58. … and you can’t cheat A B X C

  59. None
  60. None
  61. Structure Benefit Cost Method Allow reuse, 
 hide logic 2

    Class Bundle logic and data, allow reuse 2 Namespace Prevent naming collisions, group classes and methods 2
  62. Gem

  63. Gem 88 LOC Costs Create provably independent
 package of 


    code Benefits bundle gem awesome_lib Allow 
 Distribution
  64. Gem + Engine 528 LOC Costs Create provably independent
 package

    of 
 code with 
 Rails Benefits rails plugin new components/awesome_engine --full --mountable Allow 
 Distribution
  65. Structure Benefit Cost Method Allow reuse, 
 hide logic 2

    Class Bundle logic and data, allow reuse 2 Namespace Prevent naming collisions, group classes and methods 2 Component Allow Distribution, Create provably independent package of code 88 Rails Component Allow Distribution, Create provably independent package of code with Rails 528
  66. None
  67. None
  68. ML predictor X

  69. 1 component with 100 elements 1,267,650,600,228,230,000,000,000,000,000 2 component with 50

    elements 2,251,799,813,685,150 4 component with 25 elements 134,217,624 5 component with 20 elements 5,242,775 10 component with 10 elements 10,130 * assuming a lot of stuff, including complexity growing according to Reed’s law
  70. Structure Benefit Cost Method Allow reuse, 
 hide logic 2

    Class Bundle logic and data, allow reuse 2 Namespace Prevent naming collisions, group classes and methods 2 Component Allow Distribution, Create provably independent package of code 88 Rails Component Allow Distribution, Create provably independent package of code with Rails 528
  71. None
  72. 2 LOC Costs

  73. Structure Benefit Cost Method Allow reuse, 
 hide logic 2

    Class Bundle logic and data, allow reuse 2 Namespace Prevent naming collisions, group classes and methods 2 Component Allow Distribution, Create provably independent package of code 88 Rails Component Allow Distribution, Create provably independent package of code with Rails 528
  74. Let’s make it better!

  75. Share the stories of your large app!

  76. Reduce Rails component costs!

  77. Improve CI/CD integrations

  78. Fix cross-component 
 dependency versioning

  79. Can we create 
 component extractors?

  80. Street

  81. Building maintenance

  82. City

  83. Futuristic skyscraper