The model of object-oriented static language

Source: Internet
Author: User

Basic model: (Java,c#,scala)

    1. Interface, class
    2. Interfaces can inherit multiple interfaces
    3. Class can implement multiple interfaces
    4. Class can inherit only one parent class

Extended model One: Static extension (C#,swift)

    1. Static scaling is usually a behavior later in the project.
    2. Static extensions are for specific types and are poorly reusable.
    3. Extension can extend a class to add a new method to the class.

Extended model Two: Dynamic combination (Scala)

    1. Trait is similar to an interface with all or part implementations.
    2. The design of trait is a definite design behavior in the early stage of the project.
    3. Trait is a standalone structure that is designed to support reuse.
    4. When declaring a class, trait can be statically mixed into the definition of a class.
    5. When instantiating a class, trait can be dynamically mixed into an instance of a class.
    6. Prior to trait, because the implementation of multiple inheritance is not supported, if a class is to use the functionality of other classes, it is necessary to instantiate an instance of another class, which is equivalent to dynamically combining the functions of two classes during the run. After using trait, you can combine the code in a declarative form so that the written code is more readable and can be found if there is a problem in the compilation phase.

The model of object-oriented static language

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.