View Source What are anti-patterns?

Anti-patterns describe common mistakes or indicators of problems in code. They are also known as "code smells".

The goal of these guides is to document potential anti-patterns found in Elixir software and teach developers how to identify them and their pitfalls. If an existing piece of code matches an anti-pattern, it does not mean your code must be rewritten. Sometimes, even if a snippet matches a potential anti-pattern and its limitations, it may be the best approach to the problem at hand. No codebase is free of anti-patterns and one should not aim to remove all of them.

The anti-patterns in these guides are broken into 4 main categories:

  • Code-related anti-patterns: related to your code and particular language idioms and features;

  • Design-related anti-patterns: related to your modules, functions, and the role they play within a codebase;

  • Process-related anti-patterns: related to processes and process-based abstractions;

  • Meta-programming anti-patterns: related to meta-programming.

Each anti-pattern is documented using the following structure:

  • Name: Unique identifier of the anti-pattern. This name is important to facilitate communication between developers;

  • Problem: How the anti-pattern can harm code quality and what impacts this can have for developers;

  • Example: Code and textual descriptions to illustrate the occurrence of the anti-pattern;

  • Refactoring: Ways to change your code to improve its qualities. Examples of refactored code are presented to illustrate these changes.

An additional section with "Additional Remarks" may be provided. Those may include known scenarios where the anti-pattern does not apply.

The initial catalog of anti-patterns was proposed by Lucas Vegi and Marco Tulio Valente, from ASERG/DCC/UFMG. For more info, see Understanding Code Smells in Elixir Functional Language and the associated code repository.

Additionally, the Security Working Group of the Erlang Ecosystem Foundation publishes documents with security resources and best-practices of both Erlang and Elixir, including detailed guides for web applications.