# Practical difference between protocols and function pattern matching?

**URL:** <https://forum.elixirforum.com/t/practical-difference-between-protocols-and-function-pattern-matching/585>\
**Category:** Questions\
**Tags:** protocols, behaviours, pattern-matching\
**Created:** [May 12, 2016, 1:24pm UTC](https://forum.elixirforum.com/t/practical-difference-between-protocols-and-function-pattern-matching/585 "2016-05-12T13:24:11Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![gregvaughn](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/32/954_2.png) [@gregvaughn](https://forum.elixirforum.com/u/gregvaughn)\
**Post date:** [May 12, 2016, 5:00pm UTC](https://forum.elixirforum.com/t/practical-difference-between-protocols-and-function-pattern-matching/585/7 "2016-05-12T17:00:54Z")

</div>

A networking protocol is classic erlang/BEAM territory 🙂 That would be done with gen\_fsm and records. Structs are definitely the more elixir way to do it. It might be worthwhile to look at gen\_fsm for you. I know there’s some efforts underway to write a new implementation in OTP, mostly because the existing one is skewed toward networking protocols, but that’s not really a problem in your case.

Helper functions in the module that defines the struct is great in general but “handle” seems a bit too coarse grained. That probably belongs in the gen\* server that manages the specific connection. Yeah, back to the original question, that’ll mean a lot of pattern matching function heads, but you really do want low processing overhead in RTMP, so that’s my recommendation.

---

_[View the full topic](https://forum.elixirforum.com/t/practical-difference-between-protocols-and-function-pattern-matching/585)._
