2006/5/1, Brad <rtilley / vt.edu>:
> I'm not a long time Ruby coder, but I have coded for quite some time. I
> wanted to ask the groups' opinion on being more explicit with Ruby code.
> I like to code like this:
>
> Kernel.puts("Print this string")
>
> instead of this:
>
> puts "Print this string"
>
> To me, the first version is easier to read as I know where puts is
> coming from (Kernel) and what it is encapsulating. I just wonder what
> more experienced Ruby coders think of this? What would they think if
> they saw several hundred lines of code written this way? Do most find
> this type of explicitness unnecessary?
>
> I can see how the second version is easier for people new to
> programming, but it seems to me once they gain a bit of experience that
> they may want to know more about the magic behind it all. So, a more
> explicit code style may help them to see exactly how things get done in
> Ruby.

IMHO you make Ruby more verbose than necessary. One of Ruby's
strengths is that it requires less typing and clutter. If someone
wants to find out where that method is coming from there are different
means:

irb(main):001:0> method :puts
=> #<Method: Object(Kernel)#puts>

You would make *me* wonder why the "Kernel." is in there. To me that
would convey that there is a different implementation of "puts" that
you want to prevent being called. So in my case it's actually
misleading - not more information.  Of course I cannot speak for the
Ruby community but I'd suspect that it's a very widely accepted
convention to just use "puts" and thus your version would cause mild
irritation.

Kind regards

robert


--
Have a look: http://www.flickr.com/photos/fussel-foto/