ORACLENERD twitter/oraclenerd view chet justice's profile on LinkedIn feed oraclenerd t-shirts Unemployment Clock:

  Commas: Before or After the Line?

Create polls and vote for free. dPolls.com


I'm in a new group again which means I have to learn (and accept) other people's style. No one at WellCare put commas before the line (thankfully), but I've found a few here.

I've finally come to accept that this is just style and doesn't really matter, as long as the code does what it's intended to do.

Yes, it's silly, but we all have our little quirks right?

Labels: ,

 
Comments:
That's why the good Lord saw fit to create PL/SQL Developer and it beautification tool. That way everyone can write it their way.
 
True enough.

Personally, I like typing it all out myself. I don't use intellisense at all. I believe it helps me remember things better, typing them out that is.

It's sort of like the cellphone and speed dial. I used to know everyone's phone number, now I hardly know my own. I don't want the same thing to happen to my tables... ;)

chet
 
I need to vote "depends / both depending on statement"...


I type everything out as well. I justify it on the basis that it adds another sanity check.

Never trust a tab. I've never met a formatter that did things exactly as I like.
 
I always put my commas after the line, because that's what I'd do in English - I wouldn't do:

Hello there ,how are you?

It just looks wrong!

As wiser heads than mine have said, code gets written once or twice, but read many more times. So, you write your code to be read.

(I methodically go through and move every comma to after the line in code that I'm changing... which is a bit sad, really!)
 
@boneist

I do that too!

I agree, it "reads" better at the end of the line. Maybe that's why I have such a, umm...dislike for it?

chet
 
@dom

Rumor has it that the new SQL Developer formatter is very flexible...you can set it up however you want.

I've not tried it yet though. I'm still going to type it out.

chet
 
Chet,

I do commas after the line in SQL and before the line in PL/SQL. How's that for strange ;)

SQL developer 1.5 made a great leap with its formatter, but it's still lacking. I'm really looking forward to this working well so that the code can be standardized.

Regards,
Dan
 
That is strange...perhaps all your sense escaped through your hairless head? :)

Oh wait...what does that say about me?

chet
 
After the line...

Gonna have to fix that :-D

John T
 
Before the line is better in my opinion because commenting out columns doesn't leave you fiddling with commas.

Like so:

SELECT val1
,val2
,val3
,val4
FROM TABLE

I can comment out the last two columns (val3 and val4) quickly without giving a thought to making sure I put a comma at the end.

See:

SELECT val1
,val2
-- ,val3
-- ,val4
FROM TABLE

Yay! Valid SQL.

(Yes, if you comment out the first column you do have to fiddle with commas. However, I find that if I comment out columns it is almost never the first column)

However, if I wrote

SELECT val1,
val2,
val3,
val4
FROM TABLE

Commenting out val3 and val4 would leave the trailing comma after val2, which is a pain:

SELECT val1,
val2, -- BAD COLUMN HERE
-- val3,
-- val4
FROM TABLE

It gets even more annoying when I'm commenting out val4 and val2, for example. I have to do some searching and re-parsing to figure out just where all the columns go.

SELECT val1,
-- val2,
val3, -- ARGH!!!
-- val4
FROM TABLE

What's worse with comma after the line, once you are done troubleshooting (maybe bringing back some joins that you temporarily removed to see why you have too many rows) you have to go back and fiddle with your commas again to get it back to valid SQL.

Yes, comma-before may look alien at first (it did to me). However, the productivity gained by switching to it really is nice. I now tweak queries without giving much thought to where my commas are.
 
@c0ach

I hear ya. That is the one-and-only reason to ever put a comma at the front of the line.

For me, it just comes down to the way I read, from left to right. As someone else said, "it looks alien" to me. ;)
 
Post a Comment



Links to this post:

Create a Link



<<Home


Guest Authors

How To

Popular

Previous Posts

Code Projects

Archives
August 2007 / September 2007 / October 2007 / November 2007 / December 2007 / January 2008 / February 2008 / March 2008 / April 2008 / May 2008 / June 2008 / July 2008 / August 2008 / September 2008 / October 2008 / November 2008 / December 2008 / January 2009 / February 2009 / March 2009 / April 2009 / May 2009 / June 2009 / July 2009 / August 2009 / September 2009 / October 2009 / November 2009 / December 2009 / January 2010 / February 2010 / March 2010 /


Aggregated by OraNA