计算机科学与技术毕业设计论文外文翻译-高效的java异常类处理内容摘要:
proach to using Java exceptions. When the amount of exception handling code threatens to outweigh everything else, you can tell that munication between team members has broken down (or was never there in the first place), and everyone is treating exceptions their own way. The results of ad hoc exception handling are very predictable. If you ask team members why they threw, caught, or ignored an exception at a particular point in their code, the response is usually, I didn39。 t know what else to do. If you ask them what would happen if an exception they are coding for actually occurred, a frown follows, and you get a statement similar to, I don39。 t know. We never tested that. You can tell if a Java ponent has made effective use of Java exceptions by looking at the code of its clients. If they contain reams of logic to figure out when an operation failed, why it failed, and if there39。 s anything to do about it, the reason is almost always because of the ponent39。 s error reporting design. Flawed reporting produces lots of log and fet code in clients and rarely anything useful. Worst of all are the twisted logic paths, nested try/catch/finally blocks, and other confusion that results in a fragile and unmanageable application. Addressing exceptions as an afterthought (or not addressing them at all) is a major cause of confusion and delay in software projects. Exception handling is a concern that cuts across all parts of a design. Establishing architectural conventions for exceptions should be among the first decisions made in your project. Using the Java exception model properly will go a long way toward keeping your application simple, maintainable, and correct. Challenging the Exception Canon What constitutes proper use of Java39。 s exception model has been the subject of considerable debate. Java was not the first language to support exceptionlike semantics。 however, it was the first language in which the piler enforced rules governing how certain exceptions were declared and treated. Compiletime exception checking was seen by many as an aid to precise software design that harmonized nicely with other language features. Figure 1 shows the Java exception hierarchy. In general, the Java piler forces a method that throws an exception based on including that exception in the throws clause in its declaration. Also, the piler verifies that clients of the method either catch the declared exception type or specify that they throw that exception type themselves. These simple rules have had farreaching consequences for Java developers worldwide. The piler relaxes its exception checking behavior for two branches of the Throwable inheritance tree. Subclasses of and are exempt from piletime checking. Of the two, runtime exceptions are usually of greater interest to software designers. The term unchecked exception is applied to this group to distinguish it from all other checked exceptions. Figure 1 : Java exception hierarchy I imagine that checked exceptions were embraced by those who also valued strong typing in Java. After all, pilerimposed constraints on data types encouraged rigorous coding and precise thinking. Compiletime type checking helped prevent nasty surprises at runtime. Compiletime exception checking would work similarly, reminding developers that a method had potential alternate outes that needed to be addressed. Early on, the remendation was to use checked exceptions wherever possible to take maximum advantage of the help provided by the piler to produce errorfree software. The designers of the Java library API evidently subscribed to the checked exception canon, using these exceptions extensively to model almost any contingency that could occur in a library method. Checked exception types still outnumber unchecked types by more than two to one in the J2SE API Specification. To programmers, it seemed like most of the mon methods in Java library classes declared checked exceptions for every possible failure. For example, the package relies heavily on the checked exception IOException. At least 63 Java library packages issue this exception, either directly or through one of its dozens of subclasses. An I/O failure is a serious but extremely rare event. On top of that, there is usually nothing your code can do to recover from one. Java programmers found themselves forced to provide for IOException and similar unrecoverable events that could possibly occur in a simple Java library method call. Catching these exceptions added clutter to what should be simple code because there was very little that could be done in a catch block to help the situation. Not catching them was probably worse since the piler required that you add them to the list of exceptions your method throws. This exposes implementation details that good objectoriented design would naturally want to hide. This nowin situation resulted in most of the notorious exception handling antipatterns we are warned about today. It also spawned lots of advice on the right ways and the wrong ways to build workarounds. Some Java luminaries started to question whether Java39。 s checked exception model was a failed experiment. Something failed for sure, but it had nothing to do with including exception checking in the Java language. The failure was in the thinking by the Java API designers that most failure conditions were the same and could be municated by the same kind of exception. Faults and Contingencies Consider a CheckingAccount class within an imaginary banking application. A CheckingAccount belongs to a customer, maintains a current balance, and is able to accept deposits, accept stop payment orders on checks, and process ining checks. A CheckingAccount object must coordinate accesses by concurrent threads, any of which may alter its state. Chec。计算机科学与技术毕业设计论文外文翻译-高效的java异常类处理
相关推荐
序问题还没搞明白,以后要加强锻炼。 LAN 和 WAN 的设计 网络设计的 3 个 层次: 核心层( Core Layer)、汇聚层( Distribute Layer)、接入层( Access Layer)。 常用 WAN 技术: ISDN、 DDN、帧中继、 ATM、 PPP、 DSL 等。 常见 LAN 拓扑:如图所示(基于锐捷网络图标) 这只是一个模型
成提供了强有力的政治和组织保障。 确保了本年度部门目标任务和党建思政各项工作任务的全面完成。 现将一年来的工作总结如下。 ( 一 ) 围绕学院的中心工作,全面落实推进计算机科学系党总支(支部)的思想政治与组织建设。 加强理论学习。 按照院党委今年的工作要点,结合党总支(党支部)的实际,在理论联系实际、学以致用上下功夫,增强学习的针对性和实效性。 认真组织党员学习党的理论知识,主要学习了《
第四条 甲方向乙方支付技术服务报酬及支付方式为: 1.技术服务费总额为: ; 2. 技术服务费由甲方 (一次或分期)支付乙方。 具体支付方式和时间如下: ( 1) ; ( 2) ; ( 3)。 乙方开户银行名称、地址和帐号为: 开户银行: 地址: 帐号: 第五条 双方确定因履行本合同应遵守的保密义务如下: 甲方: 1. 保密内容(包括技术信息和经营信息):。 2. 涉密人员范围:。 4 3.
刚来到公司对公司各项事务还都不太熟, 所以我实习的第一件事就是和同事多了解了解公司的大体情况,工作时间注意事项和就餐时间,班车等问题,同事还是蛮热情的把基本情况都介绍了下,第一次也是带我去吃饭,感觉还是蛮好的,经过了几天的实习 我对公司的日常生活和作息时间问题都有了了解,下面就是我的工作情况了。 拿了手提装了系统和软件,基本工作配置都好了后我就开始了我的学习和工作,公司要求的语言及开发环境是
路由器除了有连接不同的网络物理分支和不同的通信媒介、过滤和隔离网络数据流及建立路由表,还有控制和管理复杂的路径、控制流量、分组分段、防止网络风暴及在网络分支之间提供安全屏障层等到功能。 根据路由设备的组成可以分为软路由和硬路由。 根据路由表的设置方式可以将路由器分为静态的和动态的。 路由器工作在网络层,因此它可以在网络层交换和路由数据帧,访问的是对方的网络地址。 当数据帧到达路由器后
== 0) amp。 amp。 (i % 77 != 0)) a[(*n)++] = i。 2求出数组 xx 中的最大数 max 及最大数的个数 t和数组 xx中的元素值能被 3或 7整除的所有数的算数平均值 pj。 int i, t1 = 0。 max = 0。 t = 0。 pj =。 for(i = 0。 i N。 i++) { if((xx[i] % 3) == 0 || (xx[i]