Names should clearly and accurately describe their purpose, avoiding abbreviations, acronyms, and misleading terms. This applies to variables, functions, types, constructors, and modules.
Names should clearly and accurately describe their purpose, avoiding abbreviations, acronyms, and misleading terms. This applies to variables, functions, types, constructors, and modules.
Key principles:
dependency_mode
instead of sca_mode
)RegularTarget
instead of Code
for a data structure that doesn’t contain code)code_of_origin
when passing multiple arguments beyond just an origin)src
over s
which could be confused with string)CSV
for comma-separated parsing that doesn’t handle CSV escaping)Example:
(* Avoid *)
type sca_mode = [ `SCA of dependency_formula ]
let code_of_origin origin = ...
let parse_csv_from_env_vars vars = ...
(* Prefer *)
type dependency_mode = [ `Dependency of dependency_formula ]
let mk_code_target xlang products origin = ...
let read_comma_separated_from_env_vars vars = ...
Names are the primary way developers understand code intent. Descriptive names reduce cognitive load, prevent misunderstandings, and make code self-documenting.
Enter the URL of a public GitHub repository