Binding

The association of a method call to the method definition

 

Two types: Compile time or Run time

 

Compile time

  • aka Early binding
  • Used for normal method calls
  • Performed if all information to invoke the method is available at the time of compilation
  • Faster since binding is completed at compilation

 

Run time

  • aka Late binding
  • Performed if information is missing at compile time, and only becomes available upon being run
  • Although slightly slower, enables response to events that occur during execution
  • Don't have┬áto write code for contingencies that might occur during run time
  • Implemented with Virtual methods
    • Using a base reference to point to the type of object used by a method
      • Sometimes this is not known until run time, and binding cannot therefore be performed during compilation
      • Must wait until the program runs to bind the method call to the method

Leave a Reply