Get the latest tech news

Elixir Anti-Patterns


View Source Code-related anti-patterns This document outlines potential anti-patterns related to your code and particular Elixir idioms and features. Comments overuse Problem When you overuse comments or comment self-explanatory code, it can have the effect of making code less readable.

This unpredictable scenario can expose the software to unexpected behavior caused by excessive memory usage, or even by reaching the maximum number of atoms possible. This anti-pattern arises when developers write defensive or imprecise code, capable of returning incorrect values which were not planned for, instead of programming in an assertive style through pattern matching and guards. This behavior, shown below, allows clients to decide how to handle these errors and doesn't give a false impression that the code is working correctly when unexpected values are extracted:

Get the Android app

Or read this on Hacker News

Read more on:

Photo of patterns

patterns

Photo of Elixir Anti-

Elixir Anti-

Related news:

News photo

Patterns of data loading: Topics and broadcast

News photo

Elixir 1.17 released: set-theoretic types in patterns, durations, OTP 27

News photo

JEP-455: Primitive types in patterns, instanceof and switch