Name
STYL-02: Adopt logical, consistent naming conventions for modules and data structures.
Synopsis
Adopt and promote standard ways to define names of program elements. Choose a level of “formality” of naming conventions based on your needs. If, for example, you have a team of two developers working on a small code base, you can probably get away with naming conventions that don’t go far beyond “use meaningful names.” If you are building a massive application involving dozens of developers, you probably need to define more comprehensive rules.
Here are some general recommendations for conventions:
Identify the scope of a variable in its name. A global variable can be prefaced with
g_
, for example.
Use a prefix or suffix to identify the types of structures being defined. Consider, for example, declarations of TYPEs: of collections, objects, records, ref cursors, etc. A standard approach to declaring such a structure is
<name>
_t
. Types are quite different from variables; you should be able to identify the difference with a glance.
Use the same case convention for user-defined types as the standard datatypes in order to help them stand out. Datatypes (built-in or user-defined) should follow a different casing rule from variables (such as all uppercase for types, lowercase for variables).
Use a readable format for your names. Since PL/SQL isn’t case-sensitive, the “camel notation” (as in minBalanceRequired), for example, is probably not a good choice for constructing names. Instead, ...
Get Oracle PL/SQL Best Practices now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.