Atitit. the extension mechanism of programming language classes and Objects . doc
1 . 1. Java Next Generation : an extension without inheritance 1
1 . 2. Inheritance 1
1 . 3. using cglib dynamic for Java class Add Method 1
1 . 4. Tool Class 1
1 . 5. Wrap wrapper class decorator mode 2
1 . 6. extension Methods (in fact, the grammar of the tool class sugar) 2
1 . 7. Scala's implicit conversions 2
1 . 8. Category class, Expandometaclass 2
1.1.Java Next Generation : an extension without inheritance
Groovy, Scala, and Clojure provide many extensibility mechanisms, but inheritance is almost the only choice for the Java™ language. This issue will introduce class classes,expandometaclass, implicit conversions, and protocols to extend Java classes using the Java Next Generation language.
Modern languages offer a variety of solutions for this purpose; In this installment, I'll highlight 3 of them :
· Open Class
· wrapper class
· Protocol
Groovy contains two ways to use Open Class The ability to extend an existing class in different ways," reopen " a class definition to implement changes such as adding, changing, or deleting a method.
author:: Nickname:Old Wow's claws( Full Name::AttilaxAkbar Al Rapanui Attilaksachanui) Kanji Name:Ayron, email:[email protected]
Reprint please indicate source: http://www.cnblogs.com/attilax/
1.2.Inheritance
1.3.use cglib dynamic for Javaclass to addMethod
1.4.Tool Class
1.5.Wrap wrapper class decorator mode
1.6.extension Methods(in fact, the grammar of the tool class sugar)
1.7. Scala's implicit conversions
Scala uses wrapper classes to solve this aspect of an expression problem
implicit conversions in Scala are a subtle and type-safe way to augment existing classes, but you cannot use this mechanism to change or delete existing methods like open classes.
1.8. category class,expandometaclass
Atitit. Extension mechanism for programming language classes and objects. doc