October 2014
Intermediate to advanced
280 pages
7h 20m
English
I’ve saved the best for last, at least when it comes to functions.
You’ve all seen code like this:
| | people = DB.find_customers |
| | orders = Orders.for_customers(people) |
| | tax = sales_tax(orders, 2013) |
| | 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), 2013)) |
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(2013) |
| | |> prepare_filing |
Read now
Unlock full access