Skip to content

Instantly share code, notes, and snippets.

@ericnormand
Last active November 18, 2025 13:35
Show Gist options
  • Select an option

  • Save ericnormand/b25712186bb210ab1c52f06655e7dfbd to your computer and use it in GitHub Desktop.

Select an option

Save ericnormand/b25712186bb210ab1c52f06655e7dfbd to your computer and use it in GitHub Desktop.
# Coffee shop scenario
Background: *This scenario is from a self-service ordering touchscreen at a coffee shop that you are assigned to develop. Jill is a customer who wants some coffee.*
Jill starts to order some coffee at the touchscreen. She adds a small, dark roast. Then
she adds a large medium roast with double almond syrup. She adds a
medium medium roast with two soy milk shots (the second one by
accident). She reads the price and it's too expensive. So she removes
the second coffee (the one with the almond syrup). Then she realizes
the third coffee has two soy milk shots and she removes one. The price
looks good, so she submits the order.
@wproffitt-elder
Copy link

wproffitt-elder commented Nov 12, 2025

;::  # Coffee shop scenario

;:: Background: *This scenario is from a self-service ordering touchscreen at a coffee shop that you are assigned to develop. Jill is a customer who wants some coffee.*

;:: Jill starts to order 

(defn start-order []) ; => Order

;:: some coffee at the touchscreen. 

(defn add-item [order]) ; => Order with a Coffee Item

;:: She adds a small, dark roast. 

(defn add-item [order]) ; => Order with a Coffee Item with two Details

;:: Then she adds a large medium roast with double almond syrup.

(defn add-item [order]) ; => Order with two specific Coffees,
; the latter of which has three Details, one of which has a quantity of 2

;:: She adds a medium medium roast with two soy milk shots (the second one by accident). 

(defn add-item [order]) ; => Order with three specific Coffees,
; the latter of which again has three Details, one with a quantity of 2

;:: She reads the price and it's too expensive. 

(defn calculate-price [order]) ; => BigDecimal

;:: So she removes the second coffee (the one with the almond syrup). 

(defn remove-item [order item]) ; => nil, and how to identify the item is a consideration

;:: Then she realizes the third coffee has two soy milk shots and she removes one. 

(defn display-order [order]) ; => visual; depending on UI, might be how she notices
; Similar use of remove-item as above


;:: The price looks good, so she submits the order.

(defn submit-order [order]) ; => nil

@joshuamzm
Copy link

Coffee shop scenario

Background: This scenario is from a self-service ordering touchscreen at a coffee shop that you are assigned to develop. Jill is a customer who wants some coffee.

(ns domain-exercise)

(defn create-order [])                                      ;;=> order
;; Jill starts to order some coffee at the touchscreen.

(defn add-coffee [order & {:keys [size]}])                  ;;=> order
;; She adds a small, dark roast.

(defn change-coffee [order coffee-id & {:keys [size addons]}]) ;;=> order
;; Then she adds a large medium roast with double almond syrup.

(defn add-coffee [order & {:keys [size addons]}])           ;;=> order
;; She adds a medium medium roast with two soy milk shots (the second one by accident).

(defn remove-coffee [order coffee-id])                      ;;=> order
;; She reads the price and it's too expensive. So she removes the second coffee (the one with the almond syrup).

(defn change-coffee [order coffee-id & {:keys [addons]}])   ;;=> order
;; Then she realizes the third coffee has two soy milk shots and she removes one.

(defn submit-order [order-id])                              ;;=> order
;; The price looks good, so she submits the order.

@jvargas
Copy link

jvargas commented Nov 12, 2025

Jill starts to order some coffee at the touchscreen.

;; Order
(defn create-order []) ;;=> Order
;; Coffee
(defn create-coffee []) ;;=> Coffee

She adds a small, dark roast.

(defn coffee-size [coffee size])    ;;=> Coffee
(defn coffee-roast [coffee roast])  ;;=> Coffee
(defn add-to-order [coffee] ;=> Order

Then she adds a large medium roast with double almond syrup.

(defn coffee-syrup [coffee syrup]   ;=> Coffee

She adds a medium medium roast with two soy milk shots (the second one by accident).

(defn coffee-mix-in [coffee mix])   ;;=> Coffee

She reads the price and it's too expensive.

So she removes the second coffee (the one with the almond syrup).

Then she realizes the third coffee has two soy milk shots and she removes one.

The price looks good, so she submits the order.

@emil0r
Copy link

emil0r commented Nov 18, 2025

Coffee shop scenario

;; Background: This scenario is from a self-service ordering touchscreen at a
;; coffee shop that you are assigned to develop. Jill is a customer who wants
;; some coffee.

;; order: Jill starts to order
;; coffee: some coffee at the touchscreen.
;; roast: She adds a small, dark roast.
;; amend-order: Then she adds a
;; coffee: large medium roast
;; complement syrup: with double almond syrup.
;; amend-order: She adds a medium
;; roast: medium roast
;; complement soy milk: with two soy milk shots
;; complement soy milk - second time: (the second one by accident).
;; She reads the price and it's too expensive.
;; amend-order (by index): So she removes the second coffee (the one with the almond syrup).
;; amend-order (remove complement by index to a coffee): Then she realizes the third coffee has two soy milk shots and she removes one.
;; execute-order: The price looks good, so she submits the order.

;; parts
;; - order - [index of coffees]
;; - coffee - [type, complements]
;; - complement - [type]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment