# Idiomatic pattern matching without arity overloading. (Single function vs mutliple)

**URL:** <https://forum.elixirforum.com/t/idiomatic-pattern-matching-without-arity-overloading-single-function-vs-mutliple/67206>\
**Category:** Questions\
**Tags:** learning-elixir\
**Created:** [November 3, 2024, 11:58am UTC](https://forum.elixirforum.com/t/idiomatic-pattern-matching-without-arity-overloading-single-function-vs-mutliple/67206 "2024-11-03T11:58:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![dimitarvp](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/32/38664_2.png) [@dimitarvp](https://forum.elixirforum.com/u/dimitarvp)\
**Post date:** [November 3, 2024, 12:22pm UTC](https://forum.elixirforum.com/t/idiomatic-pattern-matching-without-arity-overloading-single-function-vs-mutliple/67206/2 "2024-11-03T12:22:30Z")

</div>

You don’t have to duplicate `@impl true` and `@spec` for each variant of the same function. Just once is enough for the compiler and Dialyzer.

For the rest, the answer is always “it depends” but I prefer to have just one `handle_info` and then call several different private functions depending on which arm in the `case` statement you’re in. I feel it gives me the opportunity to make the code more self-documented by naming the private functions properly.

Again though, just a preference depending on the size of the code, and how unreadable it would be otherwise.

---

_[View the full topic](https://forum.elixirforum.com/t/idiomatic-pattern-matching-without-arity-overloading-single-function-vs-mutliple/67206)._
