2004-10-28 When writing a Globus Toolkit programming document, it is mentioned when implementing Operation Provider. There is no such mode in the GOF design mode, and the relevant document is found online. The translation is as follows: Entrust mode: Other classes are active. You cannot use the inheritance, and this technology must be used when using aggregation. A simple Java example: In this example, C has a socket that calls A, F () and g (). Getting up, as if there is a function of A. Class a {void f () {system.out.println ("A: doing f ()";} void g () {system.out.println ("A: doing g () "}} Class c {// delegation a a = new a (); void f () {AF ();} Void g () {Ag ();} // Normal Attributes x = new x (); Void y () {/ * do stuff * /}} void main () {c c = new c (); cf (); cg ();} Another complex Java example. Use interface entrustment to improve program Flexibility, and types of security. In this example, C progents one of the two of A and B.C can switch between A, B. Since A, B must implement the interface, this is improved Type security. As a fold, of course, you also need to write more code. Interface i {void f (); void g ();} Class a imports i {void f () {system.out.println (" A: doing f () ";} void g () {system.out.println (" a: doing g () ";}} class b import.out.println (" B: DOING F () ";} void g () {system.out.println (" B: doing g () ";}} Class C imports i {// delegation i = new a (); void f () { IF (); void g () {i ();} // n ORMAL Attributes void TOA () {i = new a ();} void Tob () {i = new b ();}} void main () {c c = new c (); cf (); cg (); } Disadvantages: This mode is a typical sacrificial performance to improve the clear level of abstract programs. (Or increase code readability)