3 ms·
I used to use the latter, in both code and maths, but I have switched to the former. My main reason is that having the operators (logical and otherwise) at the
by mkl 12y ago
I used to use the latter, in both code and maths, but I have switched to the former. My main reason is that having the operators (logical and otherwise) at the start of the line means they're more likely to be in the same horizontal position, so it's easier to see which lines are continuations of the previous ones.
- hrktb 12y agoThis, plus the stucture stays very readable even if for any specific reason a test clause has a very long line.
- deleted 12y ago[deleted]
- drglitch 12y agoIt is also easier to comment out lines of code if you need to test something. This is especially useful in SQL, where you can quickly -- a condition or a column, without editing commas etc on other lines, eg SELECT some_col , another_col --, and_another , and_more FROM blah EDIT: too bad formatting is screwed up :/
- shawnz 12y agoIsn't this behaviour exactly the same as with commas at the end? Here, to comment out the first line you would need to edit the second. With commas at the end, to comment out the last line you would need to edit the second last. Other than that, no editing of other lines is required. In fact, in a language like Javascript where extra trailing commas are allowed, it seems that this argument makes even more sense for commas at the end than it does for commas at the beginning. Then, there would never be a situation where you would have to edit a line besides the one you were commenting out.
- drglitch 12y agoNot if the line you're commenting out is the last item of a select or a join command or an AND within a where clause. Sorry Gould have made better example But it was 4 am :)
- klibertp 12y agoTrailing comma in SQL is a syntax error. It's also not allowed in JSON. And editing second last line can be a pain if you're testing something and are commenting/uncommenting the last line repeatedly.