|
|
|
|
|
by agigao
1001 days ago
|
|
Perhaps we can try to do it in a proper functional language? (ns restaurant.pizza
(:require [restaurant.oven :as oven]
[restaurant.package :as pack]))
(defn make-order [size sauce cheese kind]
{:size size
:sauce sauce
:cheese cheese
:kind kind})
(def toppings-map
{"Veg" "Veg toppings"
"Meat" "Meat toppings"})
(defn prepare [order]
(assoc order :toppings (:kind order)))
(defn bake [prepared-order]
(oven/bake prepared-order :pizza))
(defn box [baked-pizza]
(pack/box baked-pizza :pizza))
(defn pizza [order]
(-> order
prepare
bake
box))
(comment
(def order (make-order 26 "Tomato" "Mozzarella" "Meat"))
(pizza order))
It's short and overwhelmingly granular, but for the sake of illustration. Large and complex codebases sliced up this way has not alternative in terms of ease of testing and reasoning about the code. |
|