Atitit. Extension mechanism for programming language classes and objects. doc

Source: Internet
Author: User
Tags class definition

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.