May 2018
Intermediate to advanced
412 pages
9h 3m
English
I’ve saved the best for last, at least when it comes to functions.
We’ve all seen code like this:
| | people = DB.find_customers |
| | orders = Orders.for_customers(people) |
| | tax = sales_tax(orders, 2018) |
| | filing = prepare_filing(tax) |
Bread-and-butter programming. We did it because the alternative was to write
| | filing = prepare_filing(sales_tax(Orders.for_customers(DB.find_customers), 2018)) |
and that’s the kind of code that you use to get kids to eat their vegetables. Not only is it hard to read, but you have to read it inside out if you want to see the order in which things get done.
Elixir has a better way of writing it:
| | filing = DB.find_customers |
| | |> Orders.for_customers |
| | |> sales_tax(2018) |
| | |> prepare_filing |
The ...
Read now
Unlock full access