6.1. Organize Your Code

Way too many PL/SQL developers do an absolutely awful job managing their code. They put all their files into a single directory. They use short, cryptic filenames, because who's got time to type long names? And they use a single extension (.sql) for all the files.

These are all bad ideas and, as a newcomer to the world of Oracle development, you have the opportunity to establish good habits. This section offers a number of simple tips you should follow; they will make your life as a PL/SQL programmer much easier.

Before diving into the details, though, it is worth noting a couple of general principles:

We are lazy

The general tendency of most human beings is to do the smallest amount of work (especially anything like administrative work) necessary to get the job done. This "job" is often defined as that thing right in front of our nose, and we rarely take into account the likelihood that we will have to deal with this job for a long period of time.

The reality, of course, is that we (or others) will find bugs in our code, users will request enhancements, we will learn how to do things better and want to fix up our code, and so on. If we are not careful about how we write and organize our code at the start, we will soon be lost in a jungle of software. The result is that in the short term we save a few seconds or minutes, but in the long run we lose hours or days.

It's always more complicated than it first appears

You can be brand-new to programming ...

Get Learning Oracle PL/SQL 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.