Leanpub Header

Skip to main content

Gradual Modularization for Ruby and Rails

Improve collaboration, system design, and flexibility

Get yourself a new tool to manage your Rails application and your growing engineering organization! Prevent the ball-of-mud (and fix it!). Go for microservices or SOA if it makes sense not just because you don't have any other tool. Do all this through a low-overhead tool: packages. Enable better conversations to make practical changes today.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
908
Readers
272
Pages
About

About

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.

Price

Pick Your Price...

Minimum price

$24.99

$29.99

You pay

$29.99

Author earns

$23.99
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 2)

2
The author will earn $24.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

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.

Contents

Table of Contents

Acknowledgments

Introduction

1The Problems with Component-based Rails and Why Today’s Tooling Is More Powerful

  1. 1.1The inescapable challenges with components
  2. 1.2Component-based Challenges
  3. 1.2.1External dependency drift
  4. A story of dependency drift: “Oops! We just lost two orders of magnitude”
  5. 1.2.2Configuration drift
  6. A story of configuration drift: Rails initializers doing what?
  7. 1.2.3Global impact of local changes

2Getting started with packaging in a Rails application

  1. Delete the app folder?
  2. 2.1Let’s get started
  3. Comparing to CBRA
  4. 2.2From one to many packages
  5. 2.2.1Packwerk packages vs gems as components
  6. Example package structure
  7. 2.2.2A completely “packagified” application
  8. 2.2.3Introducing app/packages
  9. 2.2.4Getting things to work
  10. 2.2.5Making Packwerk packages
  11. Not all violations are created equal: ActiveRecord oh my
  12. 2.2.6Visualizing dependencies
  13. Comparing to CBRA
  14. 2.3Accepting the intended dependencies - explicitly adding package dependencies
  15. 2.4Removing the circular dependencies - creating rails_shims package
  16. 2.5Analyzing and removing root dependencies (almost) - Aligning app and test code
  17. Alternative structures
  18. 2.6Removing all dependencies from the root package
  19. 2.7Simplifying package loading
  20. 2.8Recapping differences and similarities to components

3Making Components Work with Packages

  1. 3.1Engines
  2. 3.2Gems
  3. 3.2.1Converting the gem fully into an engine
  4. 3.2.2Converting the gem into an engine (as little as possible!)

4Beyond Dependencies: Making More Modularization Gradual

  1. 4.1Gradual Modularization as A New Model for Application Composition
  2. 4.2Gradual Typing as a Role Model
  3. 4.3Commonalities of previous modularization approaches
  4. 4.4Gradularity - Modularization Game Changer
  5. 4.5Motivating More Modularity
  6. 4.6Privacy
  7. 4.7Architectural layers
  8. 4.8Visibility
  9. 4.9Folder visibility
  10. 4.10API Documentation
  11. 4.11API Typing
  12. 4.12Package Namespace
  13. 4.13API Structure
  14. 4.14Missing pieces

5Dependency Violation Management Refactorings

  1. 5.1Do absolutely nothing
  2. 5.2Accept the dependency
  3. 5.3Merge the two packages
  4. 5.4Split the violated package
  5. 5.5Move the code between packages
  6. 5.6Duplicate the functionality
  7. 5.7Abstract away the dependency
  8. 5.8Dependency injection
  9. 5.8.1Naive dependency injection
  10. 5.8.2Dependency injection with typing
  11. 5.8.3Dependency injection with typing and type abstraction
  12. 5.9Dependency Location - The service locator pattern
  13. 5.10Emit and listen to events
  14. 5.10.1To event or not to event - and where?
  15. 5.10.2Calculating backend responses with events
  16. 5.10.3Determining where to send responses
  17. 5.10.4Wiring backend and frontend together
  18. 5.10.5The package effect of eventing
  19. 5.11Beyond dependency refactorings

6Privacy Violation Management Refactorings

  1. 6.1Packages without consumers should protect their public API
  2. 6.1.1The root package
  3. 6.1.2The UI and admin packages
  4. 6.1.3packages/prediction_interface and interface classes
  5. 6.2Expose existing service classes
  6. 6.3Expose existing service classes
  7. 6.4ActiveRecord handled naively
  8. 6.5Hide ActiveRecord
  9. 6.5.1A new form of Team
  10. 6.5.2A TeamRepository to manage teams
  11. 6.5.3Migrating consumers to the new API
  12. 6.6Where are technical refactorings and to which end

7RubyAtScale

  1. 7.1The giants whose shoulders we stand on
  2. 7.2Packwerk Visual Studio Code Plugin
  3. 7.3Danger! Packwerk
  4. 7.4Code Teams
  5. 7.5ParsePackwerk and Packs::Specification
  6. 7.6Code Ownership
  7. 7.7Packs
  8. 7.8Package Statistics
  9. 7.9Honorable mentions: More of Gusto’s RubyAtScale

8Measuring Modularization Progress

  1. 8.1Basic technical measures of modularization progress
  2. 8.1.1How modularized is the app?
  3. 8.1.2Are there an adequate amount of packages?
  4. 8.1.3How much are packages owned by only one team?
  5. 8.1.4How discerning is the package dependency graph?
  6. 8.1.5Basic technical measures create a path for improvement
  7. 8.2Refining technical measures of modularization progress
  8. 8.2.1How many packages use a given structure enforcement?
  9. How many packages protect themselves from being used unintentionally?
  10. 8.2.2Usage metrics for package-quality metrics
  11. 8.3How to use technical modularization metrics
  12. 8.4Sociotechnical measures that go beyond modularization
  13. 8.4.1High-level vs low-level metrics (and tests)
  14. 8.4.2The DevOps Research and Assessment (DORA) metrics
  15. 8.4.3The SPACE framework for Developer Productivity

9How to Create Modularization Progress

  1. 9.1To start on a modularization journey
  2. Managing a multitude of options
  3. 9.2Skills - Getting started
  4. 9.3Vision - Apps and libraries
  5. 9.3.1Applications and Libraries - aspirationally!?
  6. 9.3.2Monoliths and package types
  7. 9.3.3What makes a package extractable
  8. 9.3.4Extractable library
  9. 9.3.5Extractable applications
  10. 9.3.6How far to go
  11. 9.3.7The vision behind the vision
  12. 9.4Action Plan
  13. 9.4.1Strider Bikes
  14. 9.4.2Strider bikes - what now?
  15. 9.4.3Fragments of an action plan
  16. 9.5Resources
  17. 9.6Incentives

10Polyglot Persistence, Polyglot Approaches

  1. 10.1Domain-appropriate implementation choices
  2. 10.2Domain-specific requirements balanced with application standardization
  3. 10.3Using Eventide to create a backend component
  4. 10.3.1An autonomous, event-sourced component for predictions
  5. 10.4Using Hanami inside Rails
  6. 10.4.1I’ll take a slice!
  7. 10.4.2A slice is a package
  8. 10.5Conclusion

11Archive. Gradual Modularization: A New Model for Application Composition

  1. 11.0.1Enforce Visibility
  2. 11.0.2Allow privacy circumvention
  3. External and internal tests in Go
  4. 11.0.3API versioning
  5. 11.0.4Enforcing a package namespace
  6. 11.0.5Enforcing a separate database
  7. 11.0.6Enforcing a typed API
  8. 11.0.7Enforcing proper documentation
  9. 11.0.8Configurable failure modes
  10. 11.0.9Here is my code, run it in the cloud for me, I do not care how
  11. 11.0.10Analyze to modularize the right stuff
  12. 11.0.11Caveats
  13. 11.0.12Managing the caveats

The Leanpub 60 Day 100% Happiness Guarantee

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

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

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) and EPUB (for phones, tablets and 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 and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub