Created
June 12, 2012 17:50
-
-
Save nsanta/2919007 to your computer and use it in GitHub Desktop.
Examples of "cool vs right" code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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