Last active
August 29, 2015 14:02
-
-
Save carlaviktor/0b3e7fb2aa4b6c01ac8a to your computer and use it in GitHub Desktop.
Tell, Don't Ask example
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
| # Better | |
| class Post | |
| def send_to_feed | |
| user.send_to_feed(contents) | |
| end | |
| end | |
| # Is this better or worse? | |
| class Post | |
| def send_to_feed | |
| if user.respond_to?('send_to_feed') | |
| user.send_to_feed(contents) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment