Refuting "basic object-oriented feature polymorphism"

Source: Internet
Author: User

It is often seen on the InternetArticleThe three basic features of Object-Oriented "inheritance", "encapsulation", and "polymorphism" are widely used. 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 summarized in detail the concept of polymorphism. The classification of polymorphism is given in this paper: Polymorphism (polymorphism) |-Universal

|-Parametric

| \-Transfer 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, it can be seen that polymorphism is a programming concept similar to object-oriented (1960s). It has its own independent architecture and is widely used in manyProgramming Language.

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 oneAlgorithmExpressions are used in many different types at a time, so they 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.

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.