"The Trouble with Checked Exceptions A Conversation with Anders Hejlsberg, Part II" 阅读笔记

(Anders artima 访谈系列的第二部分 )

 

"Do the simplest thing possible, but no simpler."

最近在规划一些小东西, 发现自己常常无意识的犯下过度设计的错误, 幸好看到这句话, 让我幡然醒悟.

 

"I'm a strong believer in being minimalistic."

这个系列, 七七八八看差不多了, 从中可以看出, Anders 对于 .Net 的设计, 确实是在遵循这个思路. 而 .Net 本身, 也称得上杰出了.

 

"Unless you actually are going to solve the general problem, don't try and put in place a framework for solving a specific one, because you don't know what that framework should look like."

作为一个设计过很多复杂框架, 系统的人都这样讲, 我们还有什么好说的呢.

 

关于异常处理, 有一整段非常精彩的评论, 摘抄如下

"Bill Venners : What's in the finally?

Anders Hejlsberg : In the finally, you protect yourself against the exceptions, but you don't actually handle them. Error handling you put somewhere else. Surely in any kind of event-driven application like any kind of modern UI, you typically put an exception handler around your main message pump, and you just handle exceptions as they fall out that way. But you make sure you protect yourself all the way out by deallocating any resources you've grabbed, and so forth. You clean up after yourself, so you're always in a consistent state. You don't want a program where in 100 different places you handle exceptions and pop up error dialogs. What if you want to change the way you put up that dialog box? That's just terrible. The exception handling should be centralized, and you should just protect yourself as the exceptions propagate out to the handler."

关于异常处理, 也曾困惑过, 看过网上的很多讨论, 大多限于谈玄论道, 给不出切实可行的建议. 当然, 异常处理本身很复杂, 需要见招拆招, 不能谈得很具体, 这也可以理解. 不过, 牛人之所以牛, 就在于能人所不能. Anders 这段话中提出的方式, 结合我自己的经验来看, 对于大多数的异常处理来说, 都简单, 且有效.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值