The difference between Atitit.class and type, the abstract level class, the nature of the Delegate,interface delegate
1. The delegate is a finer-grained interface 1
2. Delegation Mode 1
3. Delegation in Java 1
4. The difference between class and type 2
1. The delegate is a finer-grained interface
Interfaces (interface) are class-oriented, whereas delegates (delegate) are method-oriented and property. Interfaces must be applied on the class, and delegates are applied on methods and properties.
When the parameter of a method is a delegate type, the invocation is simpler because of the presence of an anonymous delegate. This time the method is a property, directly assigned to the parameters.
Delegation has narrowed the influence of "external constraint" to a single method, rather than affecting the entire class like an interface.
A delegate is allowed to inherit, which means that the delegate has polymorphic functions, such as using a delegate for a policy pattern.
In MSDN, class, Delegate,interface, and is listed as the three major types in. NET (type), but delegate is finer than interface granularity. Microsoft said in the relevant document, can use delegate to complete, can use interface instead.
The argument in Java is a functional interface (JDK8 only supports delegation)
Author:: Old Wow's paw Attilax Ayron, email:1466519819@qq.com
2. Delegate mode
is a basic technique in software design patterns. In delegate mode, there are two objects involved in processing the same request, and the object that accepts the request delegates the request to another object for processing. The delegate mode is a basic technique, and many other patterns, such as state mode, policy mode, and visitor pattern, are in essence a delegate mode in more special situations. The delegate mode allows us to use aggregations instead of inheritance, which also allows us to simulate mixin.
3. Delegates in Java
"Delegate" is a language-level feature in C #, and there is no direct correspondence in the Java language, but we can implement a delegate through a dynamic proxy! The code is as follows:.
Delegate is just one way of saying that in Java, the same argument is call back
JDK8 already has the implementation of the delegate: Functional interface "is the delegate of C # (delegate)
4. The difference between class and type
You can understand class as a subset of type
Type is a special class that describes the attributes of the type itself, such as the name, namespace, assembly, and properties that are owned. Method. Properties, etc., gets the owning Type:aObject.GetType () of a class instance, gets the Type:typeof keyword that belongs to a type .