In Valid Logic

Endlessly expanding technology


Last week, I gave a presentation at the SacRuby meetup on using Twilio with Sinatra.

Someone, I believe it was Jeremy Evans (author of the Sequel ORM) asked me why I was using exclusive returns at the end of my methods (code in question). It had never occurred to me and I had just answered with no reason.

While going over the video of the presentation, came across his question again and was thinking about it. I realized it is still a .NET-ism that I’m carrying. In Ruby, you don’t need to explicitly return at the end of a method. The result of the last command will automatically be returned. However in .NET, everything has to be an explicit return.

When working with multiple languages, it is interesting to see the idioms cross over. There have been multiple times I’ve been in C# and started typing “return … if …” or something similar. Much the same, I’m so used to explicit returns in C# that I’ve used them in Ruby where I didn’t really need to.

It is important to be aware of the “isms” that influence you. When moving into a new language, often times they are visible to others more familiar with the language, and more importantly, can shield you from other techniques the language offers. While many are innocent, awareness is important to help you continue to grow.

However when “isms” cross back to a language you already know, they offer a chance to gain new perspective on methodologies you already practice and a might offer an opportunity to pose the question “how can I make this better”.

Monday, May 24, 2010

blog comments powered by Disqus