技术控

    今日:82| 主题:49211
收藏本版 (1)
最新软件应用技术尽在掌握

[其他] 12.2 Helps You Manage Persistent Code Base w/New Deprecate Pragma

[复制链接]
高跟鞋的旋律 发表于 2016-10-18 14:34:58
129 0

立即注册CoLaBug.com会员,免费获得投稿人的专业资料,享用更多功能,玩转个人品牌!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
"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:
   If I were a Javascript programmer, I would probably be excited if my code lasted more than a year .
   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
IS
   /* 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
IS
   PROCEDURE proc_b;
   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:
   
12.2 Helps You Manage Persistent Code Base w/New Deprecate Pragma-1 (technology,developer,following,painfully,software)

  Yep, as suspected, you are not currently utilizing compile-time warnings. So let's start by enabling all of them:

12.2 Helps You Manage Persistent Code Base w/New Deprecate Pragma-2 (technology,developer,following,painfully,software)

  Then when I compile pkg_a, I see this warning:
123下一页
友荐云推荐




上一篇:如何在使用 Flux 时使 ReactJS 更好地发挥作用
下一篇:Week of Celebration as Scrum Turns 21
酷辣虫提示酷辣虫禁止发表任何与中华人民共和国法律有抵触的内容!所有内容由用户发布,并不代表酷辣虫的观点,酷辣虫无法对用户发布内容真实性提供任何的保证,请自行验证并承担风险与后果。如您有版权、违规等问题,请通过"联系我们"或"违规举报"告知我们处理。

*滑动验证:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

我要投稿

推荐阅读

扫码访问 @iTTTTT瑞翔 的微博
回页顶回复上一篇下一篇回列表手机版
手机版/CoLaBug.com ( 粤ICP备05003221号 | 文网文[2010]257号 )|网站地图 酷辣虫

© 2001-2016 Comsenz Inc. Design: Dean. DiscuzFans.

返回顶部 返回列表