by garrettdimon on 6/14/19, 2:19 PM with 47 comments
by pjungwir on 6/14/19, 4:31 PM
My own taste is for a "book style": write the code like you see in good books. I agree with most of this guide, although I'm pretty loose and case-by-case in practice. I've gradually added rubocop to lots of my projects, but then I wind up disabling tons of the rules.
I'm sad all the Ruby guides I've seen ban "and" and "or". I don't find them to be such an issue, and they are nicer to type & read. For one thing you can say `foo or raise "msg"` but need parens to say `foo || raise("msg")`. On team projects I sigh and go along with it, but it is a shame.
Speaking of "book style": 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'Reilly. What is going on with the Python world? Are their thumbs tired from all that indentation, so they leave out spaces everywhere else? ;-)
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:
SELECT a, b
FROM t1
LEFT OUTER JOIN t2
ON t2.t1_id = t1.id
WHERE t2.c = 'foo';
(EDIT: Sorry, t2.c = 'foo' is a pretty dumb thing to do in an outer join. :-)Other people like to do one or more of these things:
SELECT a
, b
FROM t1
LEFT OUTER JOIN t2 ON t2.t1_id = t1.id
WHERE t2.c = 'foo';
In other words:- lead with the comma in SELECT.
- ragged left edge but line up all the single spaces in a column.
- indent the joins.
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't like giving their opinion? :-)
by danmaz74 on 6/14/19, 5:17 PM
by steveklabnik on 6/14/19, 4:34 PM
1: https://github.com/rubocop-hq/ruby-style-guide/issues/273
by intsunny on 6/14/19, 8:45 PM
When reading code, my eye will immediately notice the `return` keyword and will have less to think about in terms of code execution.
The `return` keyword makes for great readability.
by onnnon on 6/14/19, 8:00 PM
https://github.com/testdouble/standard
Lightning talk about it here:
https://www.youtube.com/watch?v=uLyV5hOqGQ8
Edit: I posted it on its own if you want to discuss:
by h1d on 6/14/19, 4:19 PM
by hderms on 6/15/19, 1:47 AM
by weeksie on 6/14/19, 6:24 PM
by pswenson on 6/14/19, 5:19 PM
by abakus on 6/14/19, 8:02 PM
by tigrezno on 6/14/19, 6:01 PM