O'Reilly logo

Domain Modeling Made Functional by Scott Wlaschin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required