142 Chapter 5
The GUI needs to be exible
The barista is under a lot of pressure. Customers are throwing out
orders in arbitrary ways, mixing up the roast, the size, and the
add-ins. Plus they change their minds halfway through ordering.
We want the GUI to allow as much or more exibility as the cus-
tomer feels they have in ordering. That exibility includes:
1. Specifying the attributes (size and roast) in arbitrary order.
2. Specifying the add-ins in arbitrary order.
3. Making corrections to anything said previously.
In addition, the barista will make mistakes in hearing and mis-
takes in tapping the touchscreen. They need to correct those
mistakes as well. For instance, they might tap almond twice by
mistake and have to remove an almond. Or they might develop
adaptive habits, like setting the size twice because sometimes
the screen is a little aky. We want to allow for those things. In
the end, we want to get the customer’s order correct, as if they
told it to us perfectly with no mistakes.
We could build the exibility into the UI. But what would that
look like? It would require us to build another model, where you
could touch “set size to galactic” twice, or be able to correct add-
ing too much almond by removing the extra almond. Then we
would convert this into the “real” order encoding. Why not build
it into the model itself when it makes sense?
Here’s another way to think about it. The if statements (condi-
tionals) that implement these behaviors need to live somewhere.
Do they live in the GUI or in the domain model? Are they intrinsic
properties of the domain? Or are they eeting choices for how the
GUI works? We must make these design decisions for ourselves.
However, here are some factors to help you choose:
• Does the behavior allow for total functions?
• Are there plausible GUIs that wouldn’t want the behavior?
• Do the choices prohibit the GUI from adding new behavior?
In the case of the orders GUI, the domain operations remain total,
I can’t imagine a GUI that wouldn’t want these behaviors, and we
can always make a GUI that throws errors if you set the size twice.
We’ll return to this idea in more detail in the Layers Lens.