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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.