Clojure Conventions
Explore the key conventions in Clojure coding that support writing clean, maintainable, and extensible programs. Understand proper naming patterns, spacing, indentation, line usage, and namespace management to ensure your code adheres to functional programming standards and best practices.
Like most languages, Clojure has conventions and best practices for the layout and organization of source code. Let’s take a look at these below.
Names
As you might have noticed, Clojure uses the kebab-case to define most of the names in Clojure, which means that the names are all in lowercase and separated by the dash symbol (-). We’ll define def, defn, bindings in general, and many others with this style.
Use PascalCase for protocols, records, structs, and types.
The names of predicate functions, which return a boolean value, should end in a question mark (?). In this way, we always know that that function is a predicate. A Clojure example is the even? function.
The names of functions that might ...