The Ruby Style Guide
Oh fun another style discussion! :-)<p>My own taste is for a &quot;book style&quot;: write the code like you see in good books. I agree with most of this guide, although I&#x27;m pretty loose and case-by-case in practice. I&#x27;ve gradually added rubocop to lots of my projects, but then I wind up disabling tons of the rules.<p>I&#x27;m sad all the Ruby guides I&#x27;ve seen ban &quot;and&quot; and &quot;or&quot;. I don&#x27;t find them to be such an issue, and they are nicer to type &amp; read. For one thing you can say `foo or raise &quot;msg&quot;` but need parens to say `foo || raise(&quot;msg&quot;)`. On team projects I sigh and go along with it, but it is a shame.<p>Speaking of &quot;book style&quot;: I have a bunch of Python books with atrocious style, e.g. no spaces between operators or even between function arguments. How can anyone read that? I even see this from high-quality publishers like O&#x27;Reilly. What is going on with the Python world? Are their thumbs tired from all that indentation, so they leave out spaces everywhere else? ;-)<p>I really want to write a SQL style guide. There seems to be almost no consensus. My own formatting is idiosyncratic and not super principled, but I feel it is the most readable and expresses structure the best. It looks like this:<p><pre><code>    SELECT  a, b
    FROM    t1
    LEFT OUTER JOIN t2
    ON      t2.t1_id = t1.id
    WHERE   t2.c = &#x27;foo&#x27;;
</code></pre>
(EDIT: Sorry, t2.c = &#x27;foo&#x27; is a pretty dumb thing to do in an outer join. :-)<p>Other people like to do one or more of these things:<p><pre><code>    SELECT a
         , b
      FROM t1
           LEFT OUTER JOIN t2 ON t2.t1_id = t1.id
     WHERE t2.c = &#x27;foo&#x27;;
</code></pre>
In other words:<p>- lead with the comma in SELECT.<p>- ragged left edge but line up all the single spaces in a column.<p>- indent the joins.<p>Anyway sorry for the rambling. :-) There is some observation that committees spend 90% of their time on trivial details and hardly discuss any of the important stuff, and style is no exception. But who doesn&#x27;t like giving their opinion? :-)