User's Manual

Appendix B.
PL/SQL Standards
Like any other part of WAF, PL/SQL code must be maintainable and professional. This means that
it must be consistent and therefore must abide by certain standards. The standards will ensure that
our product will be useful long after the current people building and maintaining it are around. This
chapter addresses some standards and guidelines that will help us achieve this goal.
This chapter is written from the experience and perspective of the Red Hat Applications development
team. Because our product is open source, these standards are useful for all developers to understand
and incorporate.
B.1. General
1. All PL/SQL code must be well documented. We must write code that is maintainable by others.
This is especially true in our case because we are building an open source toolkit, so anyone can
download and browse the source code. Our motto is, "Document like you are trying to impress
your favorite programming professor."
2. It is important to be consistent throughout an application as much as is possible given the nature
of team development. This means carrying style and other conventions such as naming within
an application, not just within one file.
B.2. Coding Standards
1. Encapsulation of related functionality is key to making our software maintainable and upgrade-
able. Try to bundle your code into packages whenever possible. This will make upgrading, bug
fixing, customizing, and many other things, a possibility.
2. When creating functions or procedures, use the following template. It demonstrates most of the
guidelines set forth in this document that correspond to functions and procedures:
create or replace procedure|function
proc_or_func_name (
param_1 in|out|inout datatype ,
param_2 in|out|inout datatype ,
...
param_n in|out|inout datatype
)
[return datatype ]
is
local_var_1 datatype
local_var_2 datatype
...
local_var_n datatype
begin
...
end proc_or_func_name ;
/
show errors
3. Always use create or replace procedure|function proc_or_func_name . It
makes reloading packages much easier and painless to someone who is upgrading or fixing a
bug.