Archives

While reviewing discussion forum postings for sqr-info.com,
I've been noticing some definite coding customs. Some of these are a little puzzling and have the effect of unnecessarily
complicating the code.

Among the very common patterns are:

An overuse of ENCODE

The mistaken belief that BEGIN-SELECT, BEGIN-SQL and their associated SQL clauses must start in column 1 (only the actual column/field names of a BEGIN-SELECT block must start there)

The practice of surrounding the concatenation operator (||) with no
whitespace whatsoever

Concatenating literal strings

Unnecessary variable assignments

Unnecessary renaming of column values

Here is an example. Suppose that we want to select the city and state from the database and
then construct a variable containing the values in the form "City, State". Most of the
sample code I've seen follows a form similar to this:

I don't know where some of these practices come from. Maybe they are left over from
rules in old versions of SQR. In any case, we can often save time, avoid bugs and make our
programs more maintainable by just taking the direct route.