This is where I record odd musings I have without worrying about writing long-form defenses of them.
-
-
Save AABoyles/6c3e601f0bab0b816689c08a76f51ec7 to your computer and use it in GitHub Desktop.
- Back of Cell Phone (interferes with wireless charging?)
- Mouse
- Door Handles
- Coffee Mug
I was working with a number of queries in SQL Server recently. I was vaguely annoyed by the formatting. It looked like this:
SELECT a
,b
,c
FROM table
Why on earth would you prepend a line with a comma? Aesthetically, I'd much prefer the same query formatted like this:
SELECT a,
b,
c
FROM table
There's literally no runtime difference. So why the former? Fast Commenting! Consider the case in which we want to alter the query to eliminate c
from the results. In the former case, we need only comment a single line:
SELECT a
,b
--,c
FROM table
In the latter, however, we need to comment out the c
, and also do a little surgery on the prior line:
SELECT a,
b--,
--c
FROM table
OK, fair enough to the way we format the query (even if it is unattractive). But why? In this case, there's a specific rule we can trace it back to: SQL Server does not permit trailing commas. This is an invalid query:
SELECT a,
FROM table
If it were valid, then we could adopt the cleaner comma-last syntax without considerations of how to efficiently comment lines.