[. NET] Quick notes on Objective C,
Quick notes in Objective C #-Dynamic Programming in C #
Static and Dynamic types have their own advantages. Static types allow the compiler to help you identify more errors, because the compiler can perform most of the checks during compilation. C # Is a static language, but it adds dynamic language features to solve problems more efficiently.
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 #
I. Directory
- 38. Understand the advantages and disadvantages of dynamic types
- 39. Use Dynamic types to express the runtime type of generic parameters
- 40. Declare parameters that accept the anonymous type as dynamic
- Forty-one. Use DynamicObject or IDynamicMetaObjectProvider to implement dynamic data-driven data types.
- . How to Use expression API
- Forty-three, use expressions to convert delayed binding to pre-binding
- Forty-four, minimize the use of dynamic types in public APIs
38. Understand the advantages and disadvantages of dynamic types
1. Dynamic types are the best tool when you need to know the parsing method for specific types of runtime.
2. The static type is preferred. The static type is more efficient than the dynamic type.
3. if you can control all types involved in a program, you can introduce an interface instead of a dynamic type, that is, interface-based programming, and implement the interface for all types that need to support the interface behavior. Through the C # type system, you can reduce the errors generated during code execution, and the compiler can also generate more efficient code.
39. Use Dynamic types to express the runtime type of generic parameters
1. Convert <T> is more suitable than Cast <T>.
40. Declare parameters that accept the anonymous type as dynamic
1. Do not over-use the dynamic type, because dynamic calling will increase the additional overhead of the system, even if it is not large.
2. Extension methods cannot be defined based on dynamic objects.
Forty-one. Use DynamicObject or IDynamicMetaObjectProvider to implement dynamic data-driven data types.
1. The simplest way to create a type with Dynamic functions is to inherit System. Dynamic. DynamicObject. If DynamicObject can be inherited directly, it is easier to create a dynamic class.
. How to Use expression API
Forty-three, use expressions to convert delayed binding to pre-binding
Forty-four, minimize the use of dynamic types in public APIs
1. Give priority to the static type of C # and minimize the scope of dynamic types. If you want to keep using dynamic features, you should directly choose a Dynamic Language instead of C #.
2. If you want to use dynamic features in a program, try not to use them in the public interface. This will limit the dynamic type to a separate object (or type.
[Blogger] Anti-Bot
Http://www.cnblogs.com/liqingwen/p/6816100.html.
[GitHub] https://github.com/liqingwen2015/XMind can download XMind
[Reference] Objective C #