48

求求你们了,别再写满屏的 try catch 了!-wx5d30212829a35的博客

 3 years ago
source link: https://blog.51cto.com/14455981/2505431
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
背景软件开发过程中,不可避免的是需要处理各种异常,就我自己来说,至少有一半以上的时间都是在处理各种异常情况,所以代码中就会出现大量的try {...} catch {...} finally {...} 代码块,不仅有大量的冗余代码,而且还影响代码的可读性。比较下面两张图,看看您现在编写的代码属于哪一种风格?然后哪种编码风格您更喜欢?丑陋的 try catch 代码块优雅的Controller上面

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK