amacgregor

amacgregor

Exploring design patterns in Elixir

I wanted to reach out to the community and see who is using design patterns and what are the ones that are relevant to FP and Elixir, as well as an overall discussion on the validity and applicability of patterns.

Now, let me start with a couple of statements that might be valuable (I might be wrong; feel free to comment):

  • Design patterns are not recipes, meaning their value is not to be implemented to the letter
  • Most Creational and Structural patterns have little to no use in the functional programming world.
  • For FP and Elixir, the most valuable and applicable patterns are going to be architectural and behavioral

Within that realm, there are a few patterns that I have identified that seem useful:

  • Circuit Breaker for managing calls to external services
  • Event Sourcing for situations that require a highly reliable audit log; CQRS is also relevant

Curious what else is being used and tried for example Sagas? Proxy? Strategy? Maybe some unique to Functional languages?

Most Liked

tomekowal

tomekowal

There is the Token pattern that is very common in many Elixir libraries. Designing Token APIs for Architecting Flow in Elixir · rrrene
I had a talk on it https://www.youtube.com/watch?v=arYOSYrjC8s but I didn’t know the name yet :smiley:

kokolegorille

kokolegorille

I have been translating this book…

…from Node to Elixir

I really like DDD and Event sourcing, I feel Elixir is a good fit for this kind of reactive programming.

It’s not a pattern, but I like to define domain events first.

al2o3cr

al2o3cr

A good place to start is the OTP Design Principles User’s Guide which describes the supervision and communication patterns used by the OTP + BEAM infrastructure.

One technique that’s seems a lot more common in languages with pattern matching is defunctionalization (and another presentation) - note that both of these require a little Haskell to fully understand the examples, but it looks kinda like Erlang.

Where Next?

Popular in Questions Top

myronmarston
The Elixir Typespec docs show the following syntax for keyword lists in typespecs: # ... | [key: type] # keyword lists...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31265 143
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 43487 311
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement