Have you ever struggled to grasp Elixir/Erlang behaviours?
This powerful building block is vital in the Elixir/Erlang ecosystem, enabling rich Open Telecom Protocol (OTP) features. It took me weeks to grasp what it is, but fear not; understanding behaviour doesn't have to take you weeks.
Behaviours serve as contracts between different modules, acting as a memorandum of understanding. Like interfaces in languages like PHP, Java, and C++, behaviours define expected functions that implementing modules must fulfil.
One such popular behaviour is GenServer, which comes out of the box in OTP. It requires the implementation module to have at least init() and handle_call() functions.
In summary, Elixir/Erlang behaviours are essential contracts that manage expectations between modules, akin to interfaces in other programming languages.
In the next parts, we'll see this in examples, with actual codes. Stay tuned.