Refuting "basic object-oriented feature polymorphism"

Source: Internet
Author: User

On the Internet, I often see articles about the three basic features of object-oriented, "inheritance", "encapsulation", and "polymorphism". I think this is the most unreliable term. This article will talk about one of the features mentioned here: polymorphism. Polymorphism is a completely orthogonal concept with object-oriented, and there is no necessary link between them. Of course, there is no reason for this. The following is a reference to polymorphism in some of the more reliable sources I have found over a long period of time.

The earliest verifiable description of polymorphism is a paper called Fundamental Concepts in Programming Languages. The discussion of polymorphism in this article is mainly used to implement the heavy-load version selection of operators, in this paper, there are two types of polymorphism: ad-hoc polymorphism and parameter polymorphism. ad-hoc polymorphism means that the system determines how to select the operator behavior based on the context. For example, all native operators are listed here. Parameter polymorphism is selected based on the parameter type. The description of parameter polymorphism in this article uses a quite "function type" example. The type of return value is determined based on the function signature of the Input Function Type parameter.


In a paper around 1985, On Understanding Types, Data discovery action, and Polymorphis elaborated On the summary of the concept of polymorphism, and the classification of polymorphism is given in this paper:
Polymorphism (polymorphism)
|-Universal
|-Parametric

|-Regression sion

-Ad-hoc
|-Overloading

-Coercio

This article is more systematic about polymorphism. There are also pdf versions on the Internet. If you are interested, please read them in detail. (Semantic sion Polymorphism sounds unfamiliar, but its other name is subtype Polymorphism, which is also the only object-oriented Polymorphism)

 

From the above development, we can see that polymorphism is a programming concept similar to object-oriented development (in 1960s). It has its own independent architecture, this concept is widely used in the design of many programming languages.

The following section describes The relationship between object-oriented and polymorphism (from The C ++ programming language ),

Since both (wintercn Note: template and abstract class according to context) allow an algorithm to be expressed once and applied to a variety of types, people sometimes refer to both as polymorphic.

This means that both the template and abstract class allow an algorithm to be expressed once and used in different types. Therefore, these two types are called polymorphism. Later, we also mentioned that abstract class provides Runtime polymorphism, while template provides compilation polymorphism. (Interestingly, even one of the representative object-oriented languages, C ++ itself involves a type of polymorphism that is unrelated to object-oriented .)

 

In fact, polymorphism is not an object-oriented private production, nor is it a basic feature of object-oriented development. The relationship between polymorphism and object-oriented development is: abstract classes in object-oriented development, it provides an implementation method of Runtime polymorphism.

 

Related Article

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.