O'Reilly logo

Oracle PL/SQL Best Practices by Steven Feuerstein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required