Structs for order
summary
Argues that Elixir structs become self-contained domain bricks rather than anonymous maps and shows concrete patterns: use Ecto schemas as structs to get casting and validations for free, implement request/response struct modules and a small plug that builds a request struct and assigns it to conn with a fallback controller for errors, and delegate business work to separate modules. Benchmarks show hand‑rolled plain struct handling is faster but Ecto validation costs are small (around six microseconds), a practical tradeoff.
AI-written summary · about
chapters (10)
- 0:00Intro
- 0:43Me: quick facts
- 1:47"Container" data types
- 2:48Contract
- 5:25Responsibility
- 8:03Ecto's embedded schema
- 9:17More practical example
- 11:07How it could be
- 14:12Before you ask
- 16:56Ecto's schema vs plain struct
related talks
43mThe Tyranny of Structurelessness
44mModular Design in Elixir
24mThe Alchemist's Code: Bringing More Value with Less Magic
38mA safer Elixir
51mA Clean, Pragmatic Architecture
41mOTP behaviours and how to behave around them
37mModern Abstractions and the Web, and avoiding Pitfalls because Life is short
33mSOLID Golden Hammer
