Early binding and late binding

Source: Internet
Author: User

Bind early or later. Bind early or later

Binding refers to the process of establishing an association between objects and their types.

Early binding means that the object is associated with its type during object declaration.

Late binding refers to ourCodeAt runtime, check whether the object provides the required methods and attributes.

 

Many people say that C # and Java are bound early, while JavaScript and Python are bound late. In fact, this is not all true.

On the one hand, C # and Java are strongly typed, And the type is described during variable declaration. Here, of course, they are bound early, so we can enjoy the convenience of code prompts in IDE, because IDE can know what type, method, and attribute of your object through your declaration, and then prompt you, at the same time, it can also help you check many types of conversion errors during compilation.

On the other hand: whether C # and Java are implementing a very important feature: During polymorphism, they are all bound late. For example, your parent class defines the virtual method, this method may be reloaded in your subclass. What subclass do you use is unknown During Variable declaration, the C ++ compiler will add a pointer to these classes during compilation. The Pointer Points to a virtual table, and there are real functions in the virtual table. This is a late binding.

 

Early binding has the following advantages:

  • Compilation Efficiency
  • Code prompt (Code intelligence awareness)
  • Compile-time type check

Late binding has the following advantages:

  • No declarative type
  • The object type can be changed at any time.

 

Some materials

Http://inmyheart.bokee.com/630168.html

Http://community.csdn.net/Expert/TopicView3.asp? Id = 5647919

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.