by default use an alias that conveys the intent or purpose of that library
componet :as system
postgress :as datastore or account-records
A meaningful alias provides clarity to the code and
Another benefit of a purpose centric name is that another library that fulfills the same purpose can more easily be used as a replacement, and only change one line of code in one namespace
Specific function name refers
Where the purpose of a library is actually the purpose of the whole namespace, then using
:refer to list the specific functions you use is a simple approach.
The most obvious example is clojure.test
(ns ,,,
(:require [clojure.test :refer [are deftest is testing]))
This defines explicitly which functions from the library are being used
As the whole library is the purpose, if you change the underlying library, then you are likely to need to change much of the code anyway.
Why not follow the design of Clojure.core
The functions in clojure.core are designed to be generic, so they have simple and usually quite terse names.
The names you create for functions and aliases in your own projects mostly provide specific implementations of behaviours. Only simple helper functions would have more generic names
If you are building a library, there may be more generic functions, however, this should be within its own specific context. Therefore with a library, the use of a meaningful alias therefore is highly valuable.
Approach to names used in require expressions
by default use an alias that conveys the intent or purpose of that library
componet :as system postgress :as datastore or account-records
A meaningful alias provides clarity to the code and
Another benefit of a purpose centric name is that another library that fulfills the same purpose can more easily be used as a replacement, and only change one line of code in one namespace
Specific function name refers Where the purpose of a library is actually the purpose of the whole namespace, then using :refer to list the specific functions you use is a simple approach.
The most obvious example is clojure.test (ns ,,, (:require [clojure.test :refer [are deftest is testing]))
This defines explicitly which functions from the library are being used As the whole library is the purpose, if you change the underlying library, then you are likely to need to change much of the code anyway.
Why not follow the design of Clojure.core The functions in clojure.core are designed to be generic, so they have simple and usually quite terse names.
The names you create for functions and aliases in your own projects mostly provide specific implementations of behaviours. Only simple helper functions would have more generic names
If you are building a library, there may be more generic functions, however, this should be within its own specific context. Therefore with a library, the use of a meaningful alias therefore is highly valuable.