Rory Walker

Jamaican | Entrepreneur | Builder | ruby-lover | Arsenal fan

my blog - rorywalker.com

giant robots smashing into other giant robots: Tell, Don't Ask

thoughtbot:

And now, a friendly message from your local Tell, don’t ask Department.

Example 1

Not so good:

<% if current_user.admin? %> <%= current_user.admin_welcome_message %> <% else %> <%= current_user.user_welcome_message %> <% end %>

Better:

<%= current_user.welcome_message %>

Example 2

Not…

  1. jcblitz reblogged this from thoughtbot
  2. tomohiro reblogged this from thoughtbot
  3. yatmsu reblogged this from thoughtbot
  4. cranekicksoftwar reblogged this from thoughtbot
  5. pure-blogging reblogged this from thoughtbot
  6. collettiquette reblogged this from thoughtbot
  7. devbootcamp reblogged this from thoughtbot
  8. oreillymedia reblogged this from thoughtbot and added:
    Tell, Don’t Ask And now, a friendly message from your local Tell, don’t ask Department. Example 1 Not so good:
  9. tayu-tau reblogged this from thoughtbot
  10. redrory reblogged this from thoughtbot
  11. karekinian reblogged this from thoughtbot and added:
    You should probably read this if you’re a developer
  12. i-accidentally-another-url reblogged this from thoughtbot and added:
    Ooh, Ruby examples.
  13. liquidzoot reblogged this from thoughtbot and added:
    Smell that code.
  14. thoughtbot posted this