Discussion on Best Practices for Function Usage in Elixir

105
clicks
Discussion on Best Practices for Function Usage in Elixir
Author pico303 discusses their confusion regarding the recommended usage of many small functions in Elixir, as advised in the book Programming Phoenix LiveView. They use the example of a function that renders a bar chart but relies on several smaller functions to return simple values like strings. The conversation in comments suggests that while these small functions may seem redundant, they serve purposes like readability, teachability, and working around Elixir’s lack of native support for constants. Different viewpoints include the use of module attributes for constants, the function's intent making the code more readable, and possible compiler optimizations.

© HashMerge 2024