---
# System prepended metadata

title: Domain Modeling made Functional / Domain Modeling with Types / Modeling Complex Data
tags: [ddd]

---

# Domain Modeling made Functional / Domain Modeling with Types / Modeling Complex Data

###### tags: `ddd`

## Modeling with Record Types

```
 	data Order =
 	    CustomerInfo
 	    AND ShippingAddress
 	    AND BillingAddress
 	    AND list of OrderLines
 	    AND AmountToBill
```

translates directly to an F# record structure

```
type Order = {
 	  CustomerInfo : CustomerInfo
 	  ShippingAddress : ShippingAddress
 	  BillingAddress : BillingAddress
 	  OrderLines : OrderLine list
 	  AmountToBill : ...
}
```

## Modeling Unknown Types

```
type CustomerInfo = Undefined
 	type ShippingAddress = Undefined
 	type BillingAddress = Undefined
 	type OrderLine = Undefined
 	type BillingAmount = Undefined
 	
 	type Order = {
 	  CustomerInfo : CustomerInfo
 	  ShippingAddress : ShippingAddress
 	  BillingAddress : BillingAddress
 	  OrderLines : OrderLine list
 	  AmountToBill : BillingAmount
 	  }
```

This approach means that you can keep modeling the domain with types and compile the code. 
But when you try to write the functions that process the types, 
you will be forced to replace Undefined with something a bit better.

## Modeling with Choice Types

```
data ProductCode =
 	    WidgetCode
 	    OR GizmoCode
 	
data OrderQuantity =
 	    UnitQuantity
 	    OR KilogramQuantity
```

```
type ProductCode =
 	  | Widget of WidgetCode
 	  | Gizmo of GizmoCode
 	
type OrderQuantity =
 	  | Unit of UnitQuantity
 	  | Kilogram of KilogramQuantity
```