Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #2

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ guide for the benefit of the entire Ruby community.
## Syntax

* Use **def** with parentheses when there are arguments. Omit the parentheses when the method doesn't accept any arguments.

def some_method
# body omitted
end
Expand All @@ -80,6 +81,7 @@ guide for the benefit of the entire Ruby community.
end

* Never use **for**, unless you exactly know why. Most of the time iterators should be used instead.

arr = [1, 2, 3]

# bad
Expand Down Expand Up @@ -107,6 +109,7 @@ guide for the benefit of the entire Ruby community.
wrong operators.)
* Avoid multiline ?: (the ternary operator), use **if/unless** instead.
* Favor modifier **if/unless** usage when you have a single-line body.

# bad
if some_condition
do_something
Expand All @@ -119,6 +122,7 @@ guide for the benefit of the entire Ruby community.
some_condition && do_something

* Favor **unless** over **if** for negative conditions:

# bad
do_something if !some_condition

Expand All @@ -127,9 +131,11 @@ guide for the benefit of the entire Ruby community.

# another good option
some_condition || do_something

* Suppress superfluous parentheses when calling methods, but keep them
when calling "functions", i.e. when you use the return value in the
same line.

x = Math.sin(y)
array.delete e

Expand Down Expand Up @@ -197,9 +203,11 @@ guide for the benefit of the entire Ruby community.

* When using **inject** with short blocks, name the arguments **|a, e|** (mnemonic: accumulator, element)
* When defining binary operators, name the argument "other".

def +(other)
# body omitted
end

* Prefer **map** over *collect*, **find** over *detect*, **find_all** over *select*, **size** over *length*. This is not a hard requirement, though - if
the use of the alias enhances readability - it's ok to use it.

Expand Down Expand Up @@ -249,7 +257,7 @@ the use of the alias enhances readability - it's ok to use it.
* Keep the code simple (subjective, but still...). Each method should have a single well-defined responsibility.
* Avoid more than 3 Level of block nesting.
* Don't overdesign. Overly complex solutions tend to be brittle and hard to maintain.
* Don't underdesign. A solution to a problem should be as simple as possible... but it should be simpler than that. Poor initial design
* Don't underdesign. A solution to a problem should be as simple as possible... but it should not be simpler than that. Poor initial design
can lead to a lot of problems in the future.
* Be consistent. In an ideal world - be consistent with the points listed here in this guidelines.
* Use common sense.