Shopify Engineering Icon

Shopify Engineering

Stories from the people who build and scale Shopify, the leading cloud-based, multi-channel commerce platform that powers over 800,000 businesses in approximately 175 countries.
engineering.shopify.com • 5 Stories
All Sources

Shopify Engineering Icon Shopify Engineering

Refactoring legacy code with the Strangler Fig pattern

This is an excellent refactoring story using one of Shopify’s core classes.

As you can imagine, one of the most critical areas in Shopify’s Ruby on Rails codebase is the Shop model. Shop is a hefty class with well over 3000 lines of code, and its responsibilities are numerous. When Shopify was a smaller company with a smaller codebase, Shop’s purpose was clearer: it represented an online store hosted on our platform. Today, Shopify is far more complex, and the business intentions of the Shop model are murkier. It can be described as a God Object: a class that knows and does too much.

They use Martin Fowler’s Strangler Fig pattern to achieve the refactoring. You may recall we discussed this on our episode with Amal Hussein.

Shopify Engineering Icon Shopify Engineering

React Native is the future of mobile at Shopify

Facebook’s ‘learn once, write anywhere’ mobile framework gets a huge vote of confidence:

After years of native mobile development, we’ve decided to go full steam ahead building all of our new mobile apps using React Native. As I’ll explain, that decision doesn’t come lightly.

So why the switch to React Native? And why now? How does this fit in with our native mobile development? It’s a complicated answer that’s best served with a little background.

The biggest reason seems to be exactly what React Native promises: knowledge transfer between web and mobile with React at the heart of it all. But there’s a lot more to the story, so definitely click through and read for yourself.

Shopify Engineering Icon Shopify Engineering

How to write fast code in Ruby on Rails

If I had to pick one engineering team to write up how they make (and keep) Rails running fast, it’d be Shopify’s. What a treat!

Part of Shopify’s success with Ruby on Rails is an emphasis on writing fast code. But, how do you really write fast code? Largely, that’s context sensitive to the problem you’re trying to solve. Let’s talk about a few ways to start writing faster code in Active Record, Rails, and Ruby.

Shopify Engineering Icon Shopify Engineering

Deconstructing the monolith

Shopify’s engineering team has been doing some serious engineering on their codebase:

Shopify is one of the largest Ruby on Rails codebases in existence. It has been worked on for over a decade by more than a thousand developers. It encapsulates a lot of diverse functionality from billing merchants, managing 3rd party developer apps, updating products, handling shipping and so on. It was initially built as a monolith, meaning that all of these distinct functionalities were built into the same codebase with no boundaries between them. For many years this architecture worked for us, but eventually, we reached a point where the downsides of the monolith were outweighing the benefits. We had a choice to make about how to proceed.

Click through for a breakdown of the benefits/drawbacks of monoliths and what they build to address the drawbacks without losing the benefits.

Deconstructing the monolith
0:00 / 0:00