Coding Standards and Code Formatters

Learn and practice code standards and code formatters in this lesson.

Need for coding standards

Every programming language has built-in idioms and practices that collectively shape the look and feel of a codebase’s structure and contents. That’s coding style. Good style is especially important to adoption because it reduces friction between developers and makes a collective codebase easier to read.

As we can imagine, some tools can help us manage many of these elements automatically. Such tools are typically divided into two categories:

  1. Code formatters focus on code layout concerns, such as indentation, use of spaces and newlines, line length, and the like.

  2. Linters focus on code quality and code structure concerns that go beyond layouts, such as function and variable names.

The Elixir community embraced linters years ago but formatters are a more recent addition. Let’s start with them.

Code formatters

You and your teams have probably already had one or more heated discussions about code style. Should we use tabs or spaces? Should we add spaces after commas or not? To mature, all new language communities must go through these discussions at some point.

Even when teams are in perfect agreement and choose a style guide that already exists in the community, enforcing such guidelines requires constant effort during development as well as code reviews. To make matters worse, as a company grows, each new developer needs to get acquainted with the house rules, and that may take some time to get used to.

Get hands-on with 1200+ tech skills courses.