view counter

PL/SQL Challenge Update: Roundtable discussion on naming conventions

Thanks to Steven Feuerstein for this story

The second Roundtable discussion at the PL/SQL Challenge focuses on an issue that every developer grapples with: how to name our identifiers. That is, what are our naming conventions?

view counter

There have been many approaches to creating names, including CamelCase and Hungarian notation.

A longtime PL/SQL Challenge player, John Hall, offers a very different approach:

Identifiers can be considered a form of documentation, which raises the question, "What should an identifier's name document?"I propose this core principle: "Identifier names are based solely on the problem domain concept." No prefixes for scope. No suffixes for type.

In other words, while I would usually write a block of code like this:

DECLARE
TYPE employees_t IS TABLE OF employees%ROWTYPE;
l_employees employees_t;
BEGIN
SELECT *
BULK COLLECT INTO l_employees
FROM employees;
END;

John would, instead, do the following:

DECLARE
TYPE employee_table IS TABLE OF employees%ROWTYPE;

all_employees employee_table;
BEGIN
SELECT *
BULK COLLECT INTO all_employees
FROM employees;
END;

He's already got me thinking differently about how to write my code, though I am not yet ready to force my fingertips into drastically different patterns of typing.

I encourage you to visit the Roundtable, check out the discussion, and add your own thoughts.

Read the entire article at its source

view counter