Created
September 5, 2013 18:27
-
-
Save xinmyname/6454141 to your computer and use it in GitHub Desktop.
What if we had implicit try blocks in methods if you followed the method with a catch block? I think the meaning remains clear, but we lose a few lines and indentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private bool DoWork() | |
| { | |
| DoSomething(); | |
| DoSomethingElse(); | |
| return true; | |
| } | |
| catch (Exception ex) | |
| { | |
| _log.Error(ex); | |
| return false; | |
| } | |
| // Instead of: | |
| private bool DoWork() | |
| { | |
| try | |
| { | |
| DoSomething(); | |
| DoSomethingElse(); | |
| return true; | |
| } | |
| catch (Exception ex) | |
| { | |
| _log.Error(ex); | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment