错误处理的处理 -- <Programming Language Concepts>note
来源:互联网 发布:微信视频制作软件 编辑:程序博客网 时间:2024/06/05 08:51
程序在执行中可能出错,出错后的处理方法大体有两种:使用返回值(比如C语言),使用异常处理(Java C++ Python Ruby等)。
返回值的方法可能存在问题: 错误遗漏;干扰主流程影响代码阅读;
对于问题2,VB的处理是集中错误处理;对应引发的问题是:debug不便,对于异常无法快速定位。
使用异常处理的好处是,不会遗漏异常。但当函数存在多个出口时,必须成对处理的操作很难处理异常。
谷歌在其编程守则Google C++ Style Guide 中禁止异常使用。
Exceptions
We do not use C++ exceptions.
Decision:
On their face, the benefits of using exceptions outweigh the costs, especially in new projects. However, for existing code, the introduction of exceptions has implications on all dependent code. If exceptions can be propagated beyond a new project, it also becomes problematic to integrate the new project into existing exception-free code. Because most existing C++ code at Google is not prepared to deal with exceptions, it is comparatively difficult to adopt new code that generates exceptions.
两种方法各有优劣。
- 错误处理的处理 -- <Programming Language Concepts>note
- Programming Language Design Concepts
- The Swift Programming Language 翻译 —— 错误处理
- [golang note] 错误处理
- codeforces 200D Programming Language 字符串处理
- The Swift Programming Language学习笔记(十九)——错误处理
- Briefing introduction to four programming language concepts
- c programming language learn note 4
- 【note】the swift programming language Swift教程笔记
- Note-02-字符串处理
- MySql错误处理-错误处理的例子
- Unix Network Programming(2)---错误处理:包裹函数
- PB的错误处理
- Bean的错误处理。
- wxWidgests的错误处理
- mysql的错误处理
- 段错误的处理
- C#的错误处理
- Android框架收集
- LeetCode—Minimum Size Subarray Sum
- Java总结篇系列:Java泛型
- Android的Listview用法总结和Adapter的使用
- 使用Redis+php-resque实现消息队列
- 错误处理的处理 -- <Programming Language Concepts>note
- RabbitMQ消息队列在PHP下的应用
- Lateral View语法
- 微信企业红包开发(php)
- 史上最全的开源库整理
- 新浪微博API自动登录流程
- iOS-UITableCell详情
- C语言实现一般线性表的顺序存储
- 系统出错, 发生系统错误 1067, 进程意外终止. 解决方法