nayaread
HomeFavouritesTopicsSources
HomeFavouritesTopicsSources
NayaRead links to original engineering blogs. All copyright belongs to the respective authors.
Shopify Engineering·Feb 7, 2024·17 min read55

A Packwerk Retrospective - Shopify

This article was originally posted on the Rails at Scale blog. In September, 2020, our team at Shopify released a Ruby gem named Packwerk, a tool to enforce boundaries and modularize Rails applications. Since its release, Packwerk has taken on a life of its own, inspiring blog posts, conference talks, and even an entire gem ecosystem. Its popularity is an indication that Packwerk clearly filled a void in the Rails community. Packwerk is a static analysis tool, similar to tools like Rubocop and Sorbet. Applied to a codebase, it analyzes constant references to help decouple code and organize it into well-defined packages. But Packwerk is more than just a tool. Over the years, Packwerk’s approach to modularity has come to embody distinct and sometimes conflicting perspectives on code organization and its evolution. Packwerk’s feedback can change the entire trajectory of a codebase to a degree that distinguishes it from other tools of its kind. This retrospective is our effort, as the team that developed Packwerk at Shopify, to shine a light on our learnings working with the tool, concerns about its use, and hopes for its future. Origins of Packwerk Packwerk as a Dependency Management Tool “I know who you are and because of that I know what you do.” This knowledge is a dependency that raises the cost of change. – Sandi Metz, Practical Object-Oriented Design in Ruby Sandi Metz’ quote above captures the spirit from which Packwerk was born. The premise is simple. To use Packwerk, you must first do two things: Define a set of packages, captured in (possibly nested) file directories. Define a non-circular set of dependency relationships between these packages. With this done, you can then run Packwerk’s command-line tool, which will tell you where constants from one package reference constants from another package in ways that violate your stated dependency graph. Violations can be temporarily “allowed” via todo files (package_todo.yml); this makes it possible to “declare bankruptcy” in a codebase by generating a todo

Read original on shopify.engineering

Score breakdown

  • Technical depth85
  • Practical value45
  • Originality100
  • Writing quality100
  • Source reputation0
  • Recency0
  • External engagement0
  • On-site engagement0

NayaRead shows a summary and links to the original article. The full article is hosted on shopify.engineering.

More like this

Shopify Engineering

Enforcing Modularity in Rails Apps with Packwerk - Shopify

Sep 23, 2020·18 min read
Shopify Engineering

Shopify-Made Patterns in Our Rails Apps - Shopify

Jul 13, 2021·10 min read
Shopify Engineering

The State of Ruby Static Typing at Shopify - Shopify

Dec 7, 2020·9 min read
Shopify Engineering

The Story Behind Shopify’s Isospin Tooling - Shopify

Jul 5, 2022·11 min read