OTP behaviours and how to behave around them
summary
Argues that OTP behaviours are design patterns not mere interfaces and demonstrates concrete Elixir code: replacing direct gen_server casts with a module API, extracting a reusable gen_buffer behaviour with a handle_flash callback, and keeping tests unchanged. Shows a default implementation, optional callbacks and state-in-behaviour patterns, and a non-process formatter-style behaviour. Claims this reduces duplication, makes changing implementations safe, and keeps tests and docs stable while trading a small runtime indirection for maintainability.
AI-written summary · about
chapters (10)
- 0:00Intro
- 0:54What is OTP
- 10:34Server
- 11:46Encapsulation
- 15:40Testing
- 17:55Behaviours
- 22:24Dont do this
- 23:45Be intuitive
- 29:26Default implementation
- 34:19Summary
related talks
40mComparison and Commentary on "Application Operating System"
37mModern Abstractions and the Web, and avoiding Pitfalls because Life is short
49mKeynote: How to sell Elixir (Again)
43mThe Tyranny of Structurelessness
44mModular Design in Elixir
19mOTP Update
32mruby best practice patterns
19mStructs for order
