Cleaning Up Your Framework

Learn how to improve the structure and style of our code using Elixir formatter and credo.

Improving your code structure

Part of good development practice is making sure the code is consistent, clean, and concise. Keeping your code clean and consistent is important to the long-term maintenance of your framework. You, and any future developers who later improve your codebase, will benefit from code that’s designed to be easily built upon in the future.

In this lesson, we’ll use two tools, credo and the Elixir formatter, to improve the structure and style of your code.

Using the Elixir formatter

Following the coding style of a particular programming language is important to ensure your code is readable to you and any other developers that work on your project. Fortunately, Elixir comes with a formatter that will help enforce the formatting standards of the language.

Every Mix project contains the file .formatter.exs, which contains configurations for the mix format task. It looks like this:

Get hands-on with 1200+ tech skills courses.