Skip to content

Commit

Permalink
DRY
Browse files Browse the repository at this point in the history
  • Loading branch information
elbrujohalcon committed Sep 5, 2014
1 parent da22a60 commit e27e167
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ Table of Contents:

***
##### Honor DRY
> This convention is specifically put in this list (instead of treat it as a [great idea](#great-ideas)) so that reviewers can reject PRs that include the same code several times or PRs that re-implement something that they know it's already done somewhere else.
> Don't write the same code in many places, use functions and variables for that
*Examples*: [dry](src/dry.erl)

*Reasoning*: This convention is specifically put in this list (instead of treat it as a [great idea](#great-ideas)) so that reviewers can reject PRs that include the same code several times or PRs that re-implement something that they know it's already done somewhere else.

***
##### Avoid dynamic calls
Expand Down
21 changes: 21 additions & 0 deletions src/dry.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
%% @doc this is a very very trivial example, DRY has a much wider scope but it's
%% provided just as an example
-module(dry).

-export([bad/0, good/0]).

bad() ->
case somthing:from(other, place) of
{show, _} ->
display:nicely(somthing:from(other, place));
nothing ->
display:nothing()
end.

good() ->
case somthing:from(other, place) of
{show, _} = ThingToShow ->
display:nicely(ThingToShow);
dont_show_me ->
display:nothing()
end.

0 comments on commit e27e167

Please sign in to comment.