For me, it’s leading. If I have a code or syntax problem, I find it easier to see the line missing the comma if I can look at the first char position.
Of course you may say that’s crazy, and any reasonable programmer would demand trailing commas. I’m guessing your IDE offers formatting options that allow you to choose what works best for you. A few minutes investing these could save you hours of searching through your code and probably a few headaches.
Most IDEs have way more options than you’ll ever need or investigate. But you look at code all day, often inherited from other less….artful folks. At least make it easier to read.


Twitter
RSS
GooglePlus
Facebook
Dec 14, 2010 @ 22:14:02
I understand the arguments for and sometimes I wish I did it…but, we in the west read from left to right. a comma is a natural pause, therefore, it should always be at the end.
I have mostly given up on this fight though. All I ask is that you be consistent, and consistent is ugly in your case, but that’s OK. I will live. Joking aside, I find it hard to believe that developers with more than 2 or 3 years of experience haven’t developed their own style. Sometimes upper case keywords, sometimes not. Sometimes upper case identifiers, sometimes not. How in the f can you not be consistent?
People…other people have to read your code. For the love of all things holy, get some style.
Dec 14, 2010 @ 22:53:07
” I find it hard to believe that developers with more than 2 or 3 years of experience haven’t developed their own style.”
Maybe the difference between a developer and a programmer?
Tweets that mention Trailing or Leading Commas? | 140,000 Characters or Less -- Topsy.com
Dec 14, 2010 @ 23:52:20
[...] This post was mentioned on Twitter by Jeff Smith and patch72, OraDBPedia. OraDBPedia said: Trailing or Leading Commas? http://ping.fm/5Hvam [...]
Dec 15, 2010 @ 16:37:45
I personally prefer (and put) commas at the right, but recognize that it works better if they are at the left. It’s easier to comment out columns, for example.
Making missing columns visually obvious is better because they often don’t give syntax error. Rather it interprets “select columna columnb…” as an alias. Code would be safer if the “AS” wasn’t optional for aliasing.
Dec 15, 2010 @ 17:24:33
The commenting definitely adds merit to the trailing case.
Mar 23, 2011 @ 16:50:16
About 3.5 years ago I switched to leading commas after many years of trailing commas, in everything from SQL, C, C++, C#, etc.
Leading commas make your maintenance of lists SO MUCH EASIER. SELECT lists, parameter lists, ORDER BYs, GROUP BYs, code generation. Just about everything is easier. For the same reason I use a leading logical operator, like OR and AND. Commenting, cutting and pasting and moving things around is all FAR EASIER with leading commas. What surprised me was how it took me 15 years of professional programming before I even considered doing it this way (I saw it in code-generated SQL Server code).
Mar 23, 2011 @ 17:11:29
Took me about 10 years, and only after someone asked me how to setup Toad to allow for it. When I asked why, the answer totally left me gob-smacked. The obvious isn’t always so obvious? That’s why I love Twitter. So much more exposure to smart people, willing to share.
Jun 02, 2011 @ 09:58:07
I have been using leading commas for 10+ years now. As Cade mentioned it makes it much easier to manage your code (or someone else’s). That being said, I still see different approaches to indentation and block comments that are just as personal as the placement of commas.
Jun 02, 2011 @ 10:00:31
Thanks for sharing Rob. I think we’re in the minority here, or at least the vocal minority.
Jun 02, 2011 @ 10:19:35
Go ahead and waste your time putting the commas in the front. When I autoformat your PL/SQL code through TOAD it will fix it the right way.
Jun 02, 2011 @ 10:44:51
Yeah, when it comes down to it, the developer’s IDE should make the code look the way they need it to. How it’s stored in the database, not sure it really matters. Trivial discussion really, but this has generated more comments than most topics I’ve raised here, so it’s raised a few people’s cackles
Jun 02, 2011 @ 11:48:12
I really see the advantage of trailing commas. Just ma brain is so trained for leading commas (as chet described above) – so it still hurts. Therefore I use trailing commas, even it makes me slightly more work).
Jun 02, 2011 @ 13:20:22
Yeah, don’t try to out-think yourself.
Jumpin’ Jack Flashback Tables
Jun 23, 2011 @ 09:37:47
[...] you object that my code is buggy with the commas being all wrong, please read this #shameless_plug. How much space is being used by my beer table to store data [...]
SQL Developer Quick Tip – Leading Comma Formatting
Nov 21, 2011 @ 16:49:06
[...] covered this ‘debate’ earlier in ‘Trailing or Leading Commmas.’ If you would like to get your code to FORMAT with leading commas in SQL Developer, [...]