ElixirConf 2023 - Elaine Watanabe - Exploring code smells in Elixir

Explore code smells in Elixir and how refactoring can improve code quality, increase developer productivity, and reduce errors, with best practices and tools discussed.

Key takeaways
  • Refactoring is a controlled technique to improve code quality, focusing on code smells and their causes.

  • Code smells indicate poor design, and refactoring is essential for creating a healthy system.

  • Understanding code smells helps developers improve their code and promote a common terminology and vocabulary.

  • Principles of refactoring include small behavior-preserving transformations, extracting functions, and simplifying code.

  • Code smells can be categorized into four groups: controversy, inconsistency, scope, and complexity.

  • Credo supports refactoring, highlighting issues and suggesting improvements.

  • Refactoring is not a revolution, butrather a continuous effort to improve code quality.

  • Code smells are not bugs, but indicators of poor design and potential issues in the code.

  • Refactoring is essential for improving developer productivity and reducing errors.

  • Code smells can be identified and addressed through tools and techniques, such as Credo and pattern matching.

  • Refactoring involves simplifying code, reducing complexity, and improving maintainability.

  • Code smells can indicate:

    • Duplicated code
    • Complex conditionals
    • Long functions
    • Multiple business rules
    • Unused code
  • Refactoring can improve code quality by:

    • Simplifying code
    • Reducing complexity
    • Improving maintainability
    • Enhancing readability
    • Reducing errors
  • The author suggests several tools and techniques for refactoring, including Credo, pattern matching, and extracting functions.

  • The code smells considered in this talk include namesakes, duplicated code, code with many conditions, and reused code.

  • The author emphasizes the importance of refactoring, citing the benefits of improved code quality, reduced complexity, and enhanced maintainability.