19 Jul '12, 7pm

Tell, Don't Ask

July 19, 2012 Tagged: oop tell don't ask code Comments (View) Tell, Don’t Ask 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 so good: def check_for_overheating(system_monitor) if system_monitor.temperature > 100 system_monitor.sound_alarms end end Better: system_monitor.check_for_overheating class SystemMonitor def check_for_overheating if temperature > 100 sound_alarms end end end Example 3 Not so good: class Post def send_to_feed if user.is_a?(TwitterUser) user.send_to_feed(contents) end end end Better: class Post def send_to_feed user.send_to_feed(contents) end end class TwitterUser def send_to_feed(contents) twitter_client.post_to_fee...

Full article: http://robots.thoughtbot.com/post/27572137956/tell-dont-ask

Tweets

Launching a workplace giving program? 6 questions to ask

Launching a workplace giving program? 6 questio...

greenbiz.com 19 Jul '12, 4pm

[Editor's note: This is the fifth in a series of six blog posts from EarthShare about corporate giving. Read last month's ...

Singular vs. Plural: What Search Queries Can Te...

searchengineland.com 19 Jul '12, 3pm

Customers searching with singular term are more often closer to a conversion than a customer searching for a singular term...

Ask Stina: All's Fair In Love And Golf: Fashion tips for your teenager.

Ask Stina: All's Fair In Love And Golf: Fashion...

golfdigest.com 17 Jul '12, 2pm

Q: My 19-year-old daughter likes golf, but no matter what I tell her about dress codes, she always shows up to play in tan...

dear friends... i think I want these but i can't decide.. please tell me

dear friends... i think I want these but i can'...

dsw.com 18 Jul '12, 7pm

The Rock & Candy Bogie is the perfect mix of sporty and stylish. Smooth canvas with a rubber capped toe and sport bottom m...

Chip Yates sets electric airplane speed record,...

green.autoblog.com 20 Jul '12, 11pm

Chip Yates Becomes World's Fastest Electric Aircraft Pilot by Breaking the 200-MPH Barrier for the First Time Inyokern Air...

Good thing I didn't tell her about the Hasselblad

mrbrown.com 25 Jul '12, 2pm

Good thing I didn't tell her about the Hasselblad Where in the World is MBS Man? The MBS Man goes to the moon The MBS Man:...

Tell Us What You Think: Meeting Guide Survey

icann.org 13 Jul '12, 9pm

ICANN staff publishes a printed meeting guide for each of its three annual public meetings. We are reviewing this practice...

You Ask Me I Ask Who?

You Ask Me I Ask Who?

theonlinecitizen.com 07 Jul '12, 3pm

Recently as you all know, I have been playing Singapore’s favourite question game, “You Ask Me I Ask Who”. The Finance Min...

Things Job Interviewers Shouldn't Ask For

mrbrown.com 13 Jul '12, 6am

In Singapore, companies seem to want every excruciating detail about job applicants, details which, in many countries, wou...

If you had 5 minutes with a top running coach, what would you ask? Share your questions here:

If you had 5 minutes with a top running coach, ...

opensource.runnersworld.com 16 Jul '12, 8pm

Since running my first marathon on March 4th, 2012, I have been unable to complete a run without my feet tingling and or g...

3 Little Tips for Better Running Form | Ask Coa...

I am starting to train for a half-marathon, and the more I read about proper running technique, the more confused I get. C...

"Put on your monocles you fine fancy ladies and...

ruby5.envylabs.com 27 Jul '12, 8pm

July 24th, 2012 We talk about Sublime editing, implicit gemsets with Bundler & rbenv, really secure HTTPS with HSTS header...

SHOW & TELL: Men's KG Kurt Geiger 'Alma'

SHOW & TELL: Men's KG Kurt Geiger 'Alma'

kurtgeiger.com 19 Jul '12, 10am

The below shoe sizes are given as a guide. In our experience a conversion for women's footwear between the UK and USA woul...

Please tell me what to do with the shit: Last n...

mysingaporenews.blogspot.com 27 Jul '12, 10am

Last night I went for supper. The buffet spread was so good and I ate and ate and ate. I forgot that being too greedy and ...

Tell Me Three Times: A 3-Pronged PPC Balance System

Tell Me Three Times: A 3-Pronged PPC Balance Sy...

searchenginewatch.com 10 Jul '12, 11am

We lost a client recently. Not because of anything we did (if it were that kind of story, I wouldn’t be telling it here). ...