Programming Elixir Chapter 23 Notes


Linking Modules: Behavio(u)rs and use

An Elixir behaviour is a list of functions a module is expected to implement.

  1. A behaviour module is a bit like an abstract base class.

  2. Use @callback to declare a function that must be defined.

  3. Behaviours can have a mix of callbacks and implemented functions.

  4. @callback declares the parameters and the return type.

  5. Behaviours document and enforce the public functions that must be implemented.

All notes and comments are my own opinion. Follow me at @rgacote@genserver.social