Refactoring Legacy Code with the Strangler Fig Pattern - Shopify
Mar 11, 2020

Summary
This post details the application of the Strangler Fig Pattern to refactor the monolithic Shop model in Shopify's Rails codebase. It outlines a 7-step process: defining an interface for extracted components (using Shopify Capital's locked_settings as an example), changing calls from the old system to the new, creating new data sources (tables) for new data, implementing writers in the new model to write to both new and existing data sources, and finally, removing the old system. The post emphasizes incremental changes, reversibility, and zero downtime.
More from the Code Modularity and Boundary Enforcement trail
- A Packwerk Retrospective - Shopify
- Focus On Behavior, Not State, for a More Maintainable Codebase - Shopify
- Building a Business System Integration and Automation Platform at Shopify - Shopify
- Shopify-Made Patterns in Our Rails Apps - Shopify
- Remove Circular Dependencies by Using Dependency Injection and the Repository Pattern in Ruby - Shopify