- Variable name should reflect its content.
- Variable name should reflect the name of the class of object it contains.
- Variable name should be a noun:
- in singular form when it holds one value/object at a time;
- in plural form when it holds a collection of values/objects (
Array
,ActiveRecord::Relation
).
- Prefer full words instead of abbreviations and shortcuts (except names listed in Common short variable names).
- Let
params
name to be reserved forActionController
,Grape::API
, or HTTP params in any other form. Try to come up with a meaningful name. Also, you mayattributes
to collect and pass data toModel.new
, ordata
,payload
for more generic cases.
e
- forerror
(e.g.:rescue => e
)i
- forindex
in loops or iterators