A fair and honest chat about Performance

So, I don’t see a performance issue here. What I see is that you want to preserve the price paid (for example) of a Product that is thrown into the cart and purchased. (Which is, as it should be.)

In that case, don’t put the PRODUCT in the line item. Put a proxy for the product in the line item. (To be clear: You’re going to put the PRODUCT there too, but you’re also going to copy its fields (at least the ones you care about, like PRICE – which should become price paid). Your scenario for deleting a Product is not realistic. If you want Products to be persistent (that is, let’s say you have a vendor that offers “Canned Cat” and then, “Canned Cat” becomes unavailable due to… how shall we say… regulatory concerns…). Well, DON’T LET PRODUCTS EVER BE DELETED. You instead make them UNAVAILABLE FOR PURCHASE.

So, a line item now is this:

  • A Product (which has a bunch of fields like “Price” – price is a transient value that might change over time – while that’s all very interesting, we don’t care about that – let’s just let it be… A Product’s Price means “the price this item costs RIGHT NOW”).

  • A quantity, which is a scalar value that shall never change (“User X bought 6 Canned Cat in this particular order”).

  • A price paid – a scalar value that is the price User X paid at the moment they purchased. We can call it “Price”, but don’t get confused about this… A Line Item’s Price simply represents a different thing than Product’s Price, eh? (It’s the price PAID.) When we build the line item, we grab Canned Cat’s Price and shove that into the Line Item’s Price. Now, you see, the price paid (Line Item’s Price) and Product’s Price are no longer linked.

  • A subtotal… maybe. Should we compute that in the page? Should we put that on the line item? Well, we can, but we don’t need to. This is a derived value that we can always reconstruct IF we store the Line Item’s Price (obviously, if we look at a past order, our subtotal can be incorrect if we are looking at Product’s Price (the transient, current pricing) instead of Line Item’s Price (the price paid).

None of the above has ANYTHING to do with Bubble. It’s all “app design shit” as I like to say. Your explainer video – WHICH IS AWESOME, BTW, and I wish I had your accent! – has the answer staring you in the face the whole time… “Simply do change how you are doing it.”

You may have seen this, but I do a lot of talking about carts and such in this video (which is about List Shifter, but covers these same points):

So, not to be a party pooper, but show me an example of poor performance. (Performance means “the absolute time it takes to execute some particular function”, not “I’ve not figured this out.”)

7 Likes