Gradual Modularization for Ruby and Rails
$15.99
Minimum price
$24.99
Suggested price

Gradual Modularization for Ruby and Rails

Improve collaboration, system design, and flexibility

About the Book

For the longest time, Ruby and Rails developers had gems and engines as their main tools for creating structure to manage large-scale structures within their applications. This book is about a new tool in their toolbelt: packages.

Based on the work on packwerk by Shopify packages allow a much more fluid move to modularization then components ever did. The effects are astounding: discussions about where to draw boundaries can be far less technical and focus more on the business because the underlying technology gets out of the way.

The concept underlying this is gradual modularization, which the author expects we will see spread into other languages and frameworks over the coming years. Why? Because gradual modularization allows for a not-before seen level of approachability and flexibility to modularization work. Work that required difficult decisions that were hard to reverse changes. Those decisions are now the extreme points on a spectrum of options where the right thing for the team can be somewhere in between.

  • Share this book

  • Feedback

    You must own a copy of this Book to access the forums.

    Email the Author(s)

About the Author

Stephan Hagemann
Stephan Hagemann

Stephan leads the product infrastructure engineering team at Gusto. Gusto has quite a bit of Ruby on Rails in the software behind their offerings and provides the perfect ground for the analysis of complex applications due to "Payroll" being both a deep and very wide domain. And Gusto is a lot more than payroll.

Stephan is the author of Component-based Rails Applications in which he lays out the previous iteration of Ruby and Rails modularization based on gems and engines. He is currently working on a new book called Gradual Modularization for Ruby and Rails, which improves on his previous ideas by reducing the cost of the needed work and increasing the opportunities for benefiting from it.

Find out more about Stephan at stephanhagemann.com.

Table of Contents

  • Acknowledgments
  • 1 Introduction to Package-based Rails Applications
    • 1.1 The inescapable challenges with components
    • 1.2 Component-based Challenges
      • 1.2.1 External dependency drift
      • 1.2.2 Configuration drift
      • 1.2.3 Global impact of local changes
  • 2 Getting started with packaging in a Rails application
    • 2.1 Let’s get started
    • 2.2 From one to many packages
      • 2.2.1 Packwerk packages vs gems as components
      • 2.2.2 A completely packagified application
      • 2.2.3 Introducing app/packages
      • 2.2.4 Getting things to work
      • 2.2.5 Making Packwerk packages
      • 2.2.6 Visualizing dependencies
    • 2.3 Accepting the intended dependencies - explicitly adding package dependencies
    • 2.4 Removing the circular dependencies - creating rails_shims package
    • 2.5 Analyzing and removing root dependencies (almost) - Aligning app and test code
    • 2.6 Removing all dependencies from root
    • 2.7 Recapping differences and similarities to components
  • 3 Gradual Modularization: A New Model for Application Composition
    • 3.1 Gradual Typing as a Role Model
    • 3.2 Commonalities of previous modularization approaches
    • 3.3 Gradularity - Modularization Game Changer
      • 3.3.1 Enforce Visibility
      • 3.3.2 Allow privacy circumvention
      • 3.3.3 API versioning
      • 3.3.4 Enforcing a package namespace
      • 3.3.5 Enforcing a separate database
      • 3.3.6 Enforcing a typed API
      • 3.3.7 Enforcing proper documentation
      • 3.3.8 Configurable failure modes
      • 3.3.9 Here is my code, run it in the cloud for me, I do not care how
      • 3.3.10 Analyze to modularize the right stuff
      • 3.3.11 Caveats
      • 3.3.12 Managing the caveats
  • 4 Making Components work with Packages
    • 4.1 Engines
    • 4.2 Gems
      • 4.2.1 Converting the gem fully into an engine
      • 4.2.2 Converting the gem into an engine (as little as possible!)
  • 5 Violation Management Refactorings
    • 5.1 Do absolutely nothing
    • 5.2 Accept the dependency
    • 5.3 Merge the two packages
    • 5.4 Move the code between packages
    • 5.5 Duplicate the functionality
    • 5.6 Abstract away the dependency
    • 5.7 Dependency injection
      • 5.7.1 Naive dependency injection
      • 5.7.2 Dependency injection with typing
      • 5.7.3 Dependency injection with typing and type abstraction
  • Notes

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Do Well. Do Good.

Authors have earned$11,020,212writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF, EPUB and/or MOBI files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub