Identifying Code Smells in Shopify

| 1 min read

The Shopify inventory system is based upon Products. Once you define a Product, you can decide what Variants of this product exist, and add them as needed. One sure fire code smell with inventory here is when you see a system full of identical products, added to the inventory without using Variants. This smells for the reason that it is avoiding an efficient internal algorithm for rendering products.

If you have 50 chairs for sale, and they are all the same chair, same cost, same style, same everything, except, they vary in color, do not create 50 chairs one for each color. Create one chair, with 50 variants, one for each color.

This simple code smell just sent me reeling from the reek and now it is time to fix it.