# Behaviours & Protocols

**URL:** <https://forum.elixirforum.com/t/behaviours-protocols/17245>\
**Category:** Discussions\
**Tags:** discussion, troubleshooting\
**Created:** [October 12, 2018, 10:06am UTC](https://forum.elixirforum.com/t/behaviours-protocols/17245 "2018-10-12T10:06:47Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![peerreynders](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/32/5826_2.png) [@peerreynders](https://forum.elixirforum.com/u/peerreynders)\
**Post date:** [October 12, 2018, 10:36am UTC](https://forum.elixirforum.com/t/behaviours-protocols/17245/3 "2018-10-12T10:36:03Z")

</div>

> [@mmport80](#):
>
> But, where am I going wrong?

I see the intent behind either as being quite different. However historically OO has often conflated the notion of polymorphism and implementation inheritance - so it would be very easy to fall into the same trap.

- Protocols are ultimately about polymorphism. One part is the **interface** that will give access to the same polymorphic behaviour. Then each data type wishing to expose that behaviour implements it _separately_.
- Behaviours are about separating the _generic_ **implementation** from the _specific_. A Behaviour captures the _common_ implementation for reuse and uses callbacks to invoke the specific implementation (i.e. the part that varies - a Behaviour acts more like a framework).

[Erlang OTP Design Principles: 1.2 Behaviours:](http://erlang.org/doc/design_principles/des_princ.html#behaviours)

> [@](#):
>
> **Behaviours** are formalizations of these common patterns. The idea is to divide the code for a process in a generic part (a behaviour module) and a specific part (a **callback module** ).

In OO the callback module would likely be implemented as a [Strategy](https://www.oodesign.com/strategy-pattern.html).

From a development perspective you are _implementing_ an interface and you are _implementing_ a callback module but that is focussing on the “ **what** you are doing” and the “ **how** you are doing it”.

The “ **why** you are doing it” is quite different.

---

_[View the full topic](https://forum.elixirforum.com/t/behaviours-protocols/17245)._
