Change 1: Adding Shipping Charges

For our first requirements change, let’s look at how to calculate shipping and delivery charges. Let’s say that the company wants to charge customers for shipping using a special calculation. How can we integrate this new requirement?

First we’ll need a function to calculate the shipping cost. Let’s say that this company is based in California, so shipping to local states is one price (say $5), shipping to remote states is another price (say $10), and shipping to another country is yet another price ($20).

Here’s a first pass at implementing this calculation:

 /// Calculate the shipping cost for an order
 let​ calculateShippingCost validatedOrder =
 let​ shippingAddress = validatedOrder.ShippingAddress ...

Get Domain Modeling Made Functional now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.