forked from mvolkmann/mvolkmann.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClojureCodingGuidelines.html
More file actions
55 lines (52 loc) · 1.78 KB
/
Copy pathClojureCodingGuidelines.html
File metadata and controls
55 lines (52 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR.html1/DTD.html1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Clojure Coding Guidelines</title>
<link rel="stylesheet" type="text/css" href="../common.css"/>
</head>
<body>
<h2>Clojure Coding Guidelines</h2>
<p>
The primary motivation for most of the guidelines is code readability.
</p>
<ol>
<li>
Use two spaces for indentation.
</li>
<li>
Select meaningful names for functions and variables.
Avoid acronyms that aren't commonly known.
The only acceptable one letter names are for the following variables:
i for an index and x/y/z for cartesian coordinates.
</li>
<li>
The names of predicate functions (returning a boolean)
should typically end with a question mark (?).
</li>
<li>
Prefer rewriting code to make it clear over adding comments.
If that cannot be achieved, add comments.
</li>
<li>
Limit the number of functions invoked in a single line of code
to five.
</li>
<li>
Limit the nested depth of a function definition to four.
In order to achieve this it may be necessary to
introduce local variables to hold intermediate results
or extract code into additional function definitions.
</li>
<li>
Only use anonymous functions for short function definitions
that fit comfortably on a single line.
Otherwise create a private, named function.
</li>
<li>
Do not write anonymous functions that have
arguments that are anonymous functions.
</ol>
</body>
</html>