John Fletcher wrote:

> One thing I really like about Java compared to PHP is that there’s an 
> official coding standard.

If the Official Coding Standard just... jumped off a cliff, would you?

> Bearing that in mind... I’m starting to learn Ruby and noticed there 
> doesn’t appear to be an official coding standard, nor for Rails. This 
> document basically claims to be a de facto standard, is that true 
> http://www.caliban.org/ruby/rubyguide.shtml#style?  If so I will follow 
> their conventions. Or is there a better resource? Is the community 
> fairly consistent in their coding style?  I find the Java community is 
> fairly consistent, the PHP community rather the opposite.

Ruby is supported by a real community, not a corporate oligarchy. We have no 
motive to pay some flunky to write up a document full of our leaders' whims and 
proclivities. Yet our coding standard really does exist - it is the amalgam of 
our best literature. For example:

  - 2 spaces for indentation
  - under_bar not CamelCase
  - omit unused keywords, such as return
  - omit top-level parens
  - the closer to correct English grammar the better
  - do-end on multi-line blocks
  - {} on blocks followed by .methods
  - cram everything onto one line (then wrap it funkily)

You will notice that not all of our standards make sense. Making them official 
would only exacerbate this problem.

Ruby's incredibly rich syntax powers our style. For example, the operators 'or' 
and 'and' associate more loosely than '=', so we can write:

       match.xpath('*').each do |child|
         issue = match_nodes(child, node) and
           return issue
       end

That notation looks unfamiliar, and it saves a couple of lines - without 
cramming. It also obeys the perfectly universal coding standard, "Always 
promote 
the positive path thru a method, and demote the negative or failing path. Make 
the failing path low or to the right, and run the positive path down along the 
left."

The Official Java Standard doubtless enforced that too...

-- 
   Phlip


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to