As written by William Robertson (based on Steven Feuerstein), by using coding standards supports programmers in
- Clearer Understanding
- Better Code
- Fewer decisions to make
- Easier Maintenance
Especially the document "Naming and Coding Standards for SQL and PL/SQL" perfectly describes many coding standards for Oracle's PL/SQL language.
But there are also some aspects I don't agree with them...
... ok, they are pretty good and also evangelists in PL/SQL, but anyway ...
Identifier naming conventions
This specification is really good: <Scope><Type><Primary Identifier><Modifier><Suffix>
The samples look like this:
- get_something_out(p_data in varchar2)
Pretty nice, but why are we using this kind of old-fashioned underscores?
I personally think, today we could use the camel notation.
So let's leave the underscores away and write all this stuff in mixed case (like a camel):
- getSomethingOut(pData in varchar2)
I think this looks much better. Don't you? If not, please tell me why.
I would ony use SPACES, never use TABS. We've found out that switching IDE tools or SQL developement tools are handling this TABS stuff a different way. It looks good in IDE (a) and looks awfully in IDE (b)
Using case to aid readability
Use lowercase for all keywords. As mentioned above, all user defined variables, attributes, functions, ... can be written in camel notation (mixed case).
Why using UPPER CASE keywords? I don't know. Most SQL and PL/SQL IDE's do provide keyword highlighting.
Printing code? Ok, no highlighting. But how many times do you really print your program code?
It's been recommended to use IF x = 1 instead of IF (x = 1).
I absoutelly disagree!
Ok, it's redundant bracketting and more work to do. Besides, do you also write some Java and PHP code?
Probably yes. Do you sometimes get some syntax errors? Never? Ok.
So I try to write the same syntax in all programming languages I use.
Java, PHP and PL/SQL: if (x=1)
All the other naming convention stuff is just great!
See link at the top of this post ...