Skip to content

Instantly share code, notes, and snippets.

@nsanta
Created June 12, 2012 17:50
Show Gist options
  • Select an option

  • Save nsanta/2919007 to your computer and use it in GitHub Desktop.

Select an option

Save nsanta/2919007 to your computer and use it in GitHub Desktop.
Examples of "cool vs right" code
# Cool way
class Foo < ActiveRecord::Base
end
class FooCool
def intialize(conditions)
@conditions = conditions
end
def find_foo_cool
Foo.find_by_cool(conditions)
end
end
foo = FooCool.new(conditions)
foo.find_by_cool
#Right way
class Foo < ActiveRecord::Base
def self.find_foo_right(conditions)
find_by_right(conditions)
end
end
Foo.find_foo_right(conditions)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment