-
Website
http://awads.net/wp/ -
Original page
http://awads.net/wp/2007/03/11/the-case-of-better-readable-code/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
jgarry
3 comments · 1 points
-
Andy C
22 comments · 47 points
-
dahowlett
1 comment · 2 points
-
Don Seiler
9 comments · 1 points
-
davidhaimes
4 comments · 3 points
-
-
Popular Threads
I'm a fan of init caps - there's a reason why directions signs on freeways/motorways don't use all lower case or (worse still) upper case letters, and it's because the human brain is better as interpreting when you give more visual clues to the words.
eg. from easiest to read to hardest ...
Exec DBMS_Stats.Gather_System_Stats
exec dbms_stats.gather_system_stats
EXEC DBMS_STATS.GATHER_SYSTEM_STATS
Mind you, it drives other people crazy, but that's just another advantage for me :)
That's a good argument for automated code formatting, Dave. I can reformat your code to look the way that I find most readable. Eddie - I use the code formatter that comes with TOAD - looks like it is the same one you use with SQL Navigator - interesting, but not surprising - both tools are from Quest.
Exactly. Another example:
<ol>
<li>select employee_id from employees</li>
<li>Select Employee_Id From Employees</li>
<li>SELECT employee_id FROM employees</li>
</ol>
I believe that number 3 is the easiest to read. There is a visual clue that SELECT and FROM are reserved words.
Right. I'm not surprised either that they use the same formatter.
Personally, and this is very much IMHO, I don't get the reserved word thing. The list changes with each release and with each product (SQL, SQL*Plus, PL/SQL) and if one is supposed to recognise them well enough to capitalise them then the capitalisation ought to be regarded as redundant.
IMHO
I'm with Eddie: "Select * From" is to my particular brain cluttered, twee and unreadable. I would sooner see all-lowercase, or else (as I do) routinely go through PL/SQL Developer's .kwf files adding words like COLLECT and NTILE so they show up properly.
Although I do use code formatters, my problem with them is that the default settings do criminally insane things like right-aligning SQL keywords, and they can't seem to do fairly obvious things like starting a new line for a subquery.
I'm with David on this.
With SQL, if it is not in quotes, I write it lower case. The exceptions are when I pass the code through a formatter.
If I happen to be writing PL/SQL that is to be of any consequence, I may name my variable with init cap on each word, with the initial character in lower case.
eg. thisIsMyVariableName
If it is some really serious PL/SQL (more than a 100 lines or so ) the variables will probably be prefixed with character to indicate the data type.
eg. dThisIsADateVariable
The point I'm getting here is that you can never expect everyone to like the same coding format that you like and vice versa. This makes the need to enforce code styling and formatting standards (among team members) even stronger.