12 - Misc
Avoid hashes as optional parameters. Does the method do too much? (Object initializers are exceptions for this rule).
Avoid methods longer than 10 LOC (lines of code). Ideally, most methods will be shorter than 5 LOC. Empty lines do not contribute to the relevant LOC.
If you really need "global" methods, add them to Kernel and make them private.
Use module instance variables instead of global variables.
# bad $foo_bar = 1 # good module Foo class << self attr_accessor :bar end end Foo.bar = 1Use
OptionParserfor parsing complex command line options andruby -sfor trivial command line options.Prefer
Time.nowoverTime.newwhen retrieving the current system time.Code in a functional way, avoiding mutation when that makes sense.
Do not mutate parameters unless that is the purpose of the method.
Be consistent. In an ideal world, be consistent with these guidelines.