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…

(Source: thoughtbot)

  • 19 July 2012
  • 47