Tips n Tracks

  • Increase font size
  • Default font size
  • Decrease font size
  • default color
  • black color

Reference

Sample image

Microsoft .NET Framework Get Details.

Sample image

Microsoft .NET Framework Get Details.

Reference

Sample image Microsoft .NET Framework Get Details.
Sample image

Microsoft .NET Framework Get Details.


C# Coding Standards and Guidelines: Error Handling


C# Coding Standards and Guidelines: Error Handling

1. Error handler should be present whenever you anticipate possibility of error.

2. Do not use Try-catch for flow- control.

3. Never declare an empty catch block.

4. Error Message should be user friendly, simple and understandable.

5. Errors should be raised in the routines present in the components and captured in the application’s GUI.

6. Use Try-Catch statements in each and every function you write. Adhere to it strictly with out fail.

7. Catch only exceptions for which you have explicit handling.

8. In a catch statement that throws an exception, always the original exception(or another exception constructed from original exception) to maintain the stack location of the original error:

catch (Exception exception)
{
   
Messagebox.Show (exception.Message);
   
throw;     //same as throw exception;
}

9. Avoid error code as method return values.

10. Avoid defining custom exception classes.

11. When defining custom exceptions:

  • Derive the custom exception from Exception.
  • Provide custom serialization.

12. Use dispose on types holding scarce resources, i.e., files, database connections.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

No comments yet.

Leave a comment

(required)

(required)

*
To prove that you're not a bot, enter this code
Anti-Spam Image