Created
December 13, 2011 19:47
-
-
Save edavis10/1473581 to your computer and use it in GitHub Desktop.
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
# I think we can agree that this code is best, even if contrived: | |
if @article.public? | |
views += 1 | |
else | |
redirect_to "/some/other/page" | |
end | |
# But sometimes, people don't make query methods that are positive, ie | |
unless @article.draft? | |
redirect_to "/some/other/page" | |
else | |
views +=1 | |
end | |
# I think that's better than: | |
if not @article.draft? | |
# But that's really just taste. In order to not use unless/else, you need to | |
# make sure your ? methods are asking a positive question, not a negative one. | |
# Which is ideal, but none of us are always working on ideal code, right? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment