Skip to content

Commit

Permalink
no_magic_numbers: document magic numbers (#2499)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaimonetti authored and fenollp committed Aug 30, 2016
1 parent 01c2989 commit 6ddeb68
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ Some 2600Hz specifics:
do_x() ->
lists:foldl(fun(F, Acc) -> F(Acc) end, lookup(), [fun do_y/1, do_z/1]).
```
* No [magic numbers](https://en.wikipedia.org/wiki/Magic_number_(programming)#Unnamed_numerical_constants) please
* If you are doing timeouts and similar, there are [macros](https://github.com/2600hz/kazoo/blob/master/core/kazoo/include/kz_types.hrl#L4-L15) that can help make it more apparent what the unit of time is, for instance:
```erlang
receive
X -> do_something_with(X)
after
5 * ?MILLISECONDS_IN_SECOND -> fail()
end
```
Now we can easily see that the receive will block for 5 seconds (but the value is in milliseconds)
Some additional guidance can be found:
* http://www.erlang.se/doc/programming_rules.shtml
Expand Down

0 comments on commit 6ddeb68

Please sign in to comment.