inaka/erlang_guidelines — pull request #7 by elbrujohalcon (2014-09-15 20:35:57+00:00)
Title: Suggestion: Use Macros appropriately

##### rule
> Macros should not be used as abbreviations. Also, no code should be allowed in macros, except for extenuating circumstances which must be documented.

```erlang
##### bad
-define(IS_VALID_SERVICE(__Service), lists:member(__Service, pg2:which_groups())).
-define(IS_VISIBLE_SERVICE(__Service), (lists:keyfind(__Service, 1, application:which_applications()) =/= false)).
```

##### reasoning
Having logic in macros obscures its meaning. If having the code there complicate the logic, or duplicates code, or the logic is not related to the location the macro is invoked, then the macro'ed code should be in a function, with a proper semantic name.