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

A Healthy Monolith

A Healthy Monolith

Supporting an overgrown monstrous project, a so-called Monolith that was shaped according to the tenets of the "Rails way", is a usual problem for our community. Many developers blame Rails for the fact that it allows, and even promotes, this way of project building, and that there are no tools available out of the box to make this growth healthier. I'll tell you how Evil Martians live with their own Monolith and demonstrate the that the Monolith is not in fact a problem — it's an opportunity

Nikolay Sverchkov

June 10, 2018
Tweet

More Decks by Nikolay Sverchkov

Other Decks in Programming

Transcript

  1. Cons: Strategy: merge or rebase? Atomic commits or one commit

    per feature (Pull request)? Monolith Estimation: by commits count
  2. Monolith Estimation: by count lines of code Pros: Amount of

    commits does not influence on count of code lines
  3. Monolith Estimation: by count lines of code Pros: Amount of

    commits does not influence on count of code lines Cons: There is no connection to REAL production
  4. The size of the database for a regular web application

    can be considered as “Web Big Data” when the backup of this database cannot be restored to the developer computer. Funny Law of “Web BigData”
  5. Huge Monolith: A lot of commits + A lot of

    code lines + Deep Production
  6. ------------------------------------------------------------------------------- Language files blank comment code ------------------------------------------------------------------------------- Ruby 3671 30458

    3106 145366 JSX 571 5759 43 52618 YAML 182 90 20 33753 JavaScript 492 3247 144 22763 ERB 617 1569 58 18599 Sass 480 3552 194 18024 CoffeeScript 150 874 92 5227 …… …… ------------------------------------------------------------------------------- SUM: 6231 52012 7778 306167 ------------------------------------------------------------------------------- Fountain. 30/05/2018 25.5k commits SUM: 306,167 LOC
  7. -------------------------------------------------------------------------------- Language files blank comment code -------------------------------------------------------------------------------- Ruby 13995 271122

    19124 1290867 YAML 1791 8962 1166 559395 JSON 332 77 0 303475 Sass 484 39191 4968 185032 ERB 2584 7208 83 111490 JavaScript 1065 22635 5956 109023 CoffeeScript 667 12130 1003 45734 SQL 4 14 0 28300 TypeScript 455 3794 190 23939 liquid 64 4391 28 21809 …… …… -------------------------------------------------------------------------------- SUM: 21742 376631 38507 2705978 -------------------------------------------------------------------------------- Shopify 30/05/2018 306k commits SUM: 2.7M LOC
  8. Normal • Rails 4 Healthy • Rails 5+ • Rails

    4 -> Rails 5 in process Legacy • Rails 3 and lower Monolith Healthy Level: by Rails version
  9. Normal • 2.3+ Healthy • Last stable Legacy • 1.9*

    - What wrong with you, guys? >_< Monolith Healthy Level: by Ruby version
  10. Healthy • It is easy to make changes • You

    have permanent refactor for an old code Legacy • You use Rails way (sorry, DHH) • You have a bunch of different patterns Monolith Healthy Level: by Architecture
  11. Solution Cause Rails MVC is sucks Use MCC! M -

    Model C - Cells C - Controller
  12. class UsersController < ApplicationController def show user = User.find(params[:id]) render_app_cell(Users::Cell::Show,

    user: user) end end class ApplicationController < ActionController::Base def render_app_cell(*args) render html: cell(*args), layout: 'application' end end MC(ells)C Example
  13. I

  14. Solution Cause I can use ROM! If you can work

    with complex solutions ActiveRecord is sucks