"Persistent code base"? What's that?
Well, I suppose I could have said "aging" or "legacy" code base, but that doesn't capture my point, which starts with:
As an Oracle Database developer, though, it is not unreasonable to expect that my code will be in production for years, perhaps decades .
Now, that's persistent code. And why is that?
Because, well, DATABASE .
The database is the repository for your enterprise. Certainly it contains the data, and if you fully leverage the database properly , it will also contain your business logic.
And while it is not all that painfully disruptive to rewrite your UI code, it can be business-threatening to do any of the following:
Switch your database technology
Upgrade your database software too quickly
Rewrite your business logic in a new scripting language
So your database - data and associated code - tends to be the most stable layer in your stack, with upgrades applied with great care, and code maintained for many years.
And "maintained" could mean:
True legacy mode: no further enhancements, critical bug fixes only. This will always be true for at least a part of your code base, and I will not address it further in this post.
Actively used and enhanced: this is where the action is. Sure, lots of the code has been around for years, and will continue to be. Most of it works great and doesn't need to be touched. But then there are enhancements, bug fixes, new features.
Oh, and, inevitably, deprecation. Which is the topic of this blog post.
Many things happen to code that lasts a long, and one of them is that we come up with better ways to do things. The "better" part could be a better name for a subprogram, a seriously modified parameter list, or an entirely new implementation.
And, of course, what you'd really like to do is immediately get rid of the "old stuff" and make sure everyone's program units, across the entire application, use only the cool, new stuff.
Sadly, that's not always possible. Sure you can send out an email:
Hey, folks, listen up! Don't use pkg_a.proc_b anymore. We've got a much better version in pkg_c.proc_d.
But there's no guarantee that anyone (or, more to the point: everyone ) will switch over to the new iteration. And since a published, in-use API is a sort of contract you signed with users, you can't just force them to change (usually).
So instead, the old stuff sticks around and might even get used again by a careless developer - even if you add a comment like:
[code]PACKAGE pkg_a AUTHID DEFINER
/* DON'T USE THIS! Use pkg_c.proc_d instead! */
PROCEDURE proc_b;[/code] Wouldn't it be nice if there was a way to document deprecated functionally, so that when your code is compiled, you would be notified (and could even have it flagged as a compile error) that you are using out-of-date stuff?
Yes, that sure would be lovely.
[Pretend you are now listing to a Drum Roll....]
Welcome to PL/SQL 12.2 and the DEPRECATED pragma.
You want to notify developers that proc_b is out of date and proc_d should be used instead?
This is now what you do:
[code]PACKAGE pkg_a AUTHID DEFINER
PRAGMA DEPRECATE (proc_b,
'pkg_a.proc_b deprecated. Use pkg_c.proc_d instead.');[/code] Looks really similar to the comment version, doesn't it? So what, then, does this pragma do for you? Not much, if that's all you do.
But let's suppose that you've decided your team should "step it up" in terms of code quality and overall professionalism.
As a part of that initiative, you are going to take advantage of PL/SQL's compile-time warnings . You go into SQL Developer's preferences, type "compile" in the search field, and find this:
Yep, as suspected, you are not currently utilizing compile-time warnings. So let's start by enabling all of them: