{boolean?}

Is your boolean really one?

Oh we need to support oat milk!

(if use-oat-milk?
      (make-coffee :oat-milk)
      (make-coffee :milk))


;; ALTER TABLE ingredients ADD COLUMN use_oat_milk boolean;
# Making Coffee

I guess we are branching now and need to test both cases.

A while later: Almond milk has arrived!

(cond 
   use-oat-milk?  (make-coffee :oat-milk)
   use-almond-milk? (make-coffee :almond-milk)
   :else (make-coffee))


;; ALTER TABLE ingredients ADD COLUMN use_almond_milk boolean;
# Making "Coffee"

More branching. Hopefully nobody does funky business in one of them

Booleans are smelly

;; CREATE TYPE fake_milk AS ENUM ('oat', 'almond', 'goat', 'rice', 'hemp');
;; ALTER TABLE ingredients ADD COLUMN milk fake_milk;


(def fake-milks {:oat :oat-milk :almond :almond-milk})

(make-coffee (get fake-milks milk-option))
# Milking it

Consider using a regular value and mapping to achieve more flexibility.

Bonus: no branching logic

Code

By Jochen Bedersdorfer

Code

  • 96