On October 22, I picked up a referral program halfway through. A first version applied the referral discount by writing it straight into the order line. I refused it. I wanted the discount to go through the voucher system we already have, and the referral to stay tracked.
Some context. I run backend engineering at GoodBarber , an app platform, and our customers pay for their apps through a back office that is a PHP monolith. A referral program has to touch the coupon field at checkout, the payment confirmation, invoices and credit notes, vouchers, the credits we give apps, and renewals, which a cron of our older CMS creates. All of that lives in the monolith. The question was where the referral itself should live.
Between 14:37 and 15:55 that day, I went around five answers.
Five places for the same code
A new table in the shared database, with its model. The obvious answer, and the one I liked least.…