[. NET] Quick notes on Objective C,
Quick notes in Objective C #-C # key points of efficient programming
/// <Summary> /// custom Exception class /// </summary> public class MyException: Exception {public MyException (): base () {} public MyException (string s): base (s) {} public MyException (string s, Exception e): base (s, e) {} protected MyException (SerializationInfo info, streamingContext cxt): base (info, cxt ){}}
3. When a custom exception is thrown, the original exception should be stored in the InnerException attribute so that the exception is friendly and informative:
Public void Do () {try {// DoException ();} catch (DoException e) {var msg = $ "this problem was intentionally caused by the blogger "; throw new MyException (msg, e );}}
4. Different types of exceptions should be thrown only when different types of recovery operations exist. When defining exception classes, all constructors supported in the base classes must be provided. In addition, do not forget to use the InnerException attribute to save low-level exception information.
Forty-seven, strong exception Security Guarantee
1. Dave Abrahams defines three security exceptions to ensure the program: basic assurance, strong assurance, and non-throw assurance.
2. strong exception guarantee: a balance point is provided between recovering from an exception and simplifying Exception Handling. If an operation is interrupted due to an exception, the program will remain in the original state and the operation will be completed completely, or you will not modify any State of the program. Benefits of strong exception guarantee: if an exception is caught at any time, all normal operations to be attempted will not continue. The current state of the program is the same as that of the program.
3. make a defensive copy of the data to be modified and modify the defensive copy of the data. This intermediate operation may cause exceptions, when an exception occurs, you can exchange temporary copies with the original object.
4. The Terminator, the Dispose () method, and the target method bound to the delegate object should ensure that they do not throw an exception under any circumstances.
Forty-eight, try to use safe code
Forty-nine, CLS-compatible assembly
1. the. NET runtime environment has nothing to do with the language. The created assembly must be compatible with CLS, so that other developers can use another language to call your components.
50. Small and highly cohesive assembly
This series
Quick notes in Objective C # (1)-C # language habits
Quick notes for Objective C # (2)-. NET resource hosting
Quick notes in Objective C # (III)-use C # To express design
Quick notes for Objective C # (4)-use the framework
Quick notes in Objective C #-Dynamic Programming in C #
Quick notes for Objective C # (6)-C # key points of efficient programming
[Blogger] Anti-Bot
Http://www.cnblogs.com/liqingwen/p/6827546.html.
[Reference] Objective C #