dynamic binding


dynamic binding

The property of object-oriented programming languages wherethe code executed to perform a given operation is determinedat run time from the class of the operand(s) (the receiverof the message). There may be several different classes ofobjects which can receive a given message. An expression maydenote an object which may have more than one possible classand that class can only be determined at run time. Newclasses may be created that can receive a particular message,without changing (or recompiling) the code which sends themessage. An class may be created that can receive any set ofexisting messages.

C++ implements dynamic binding using "virtual member functions".

One important reason for having dynamic binding is that itprovides a mechanism for selecting between alternatives whichis arguably more robust than explicit selection byconditionals or pattern matching. When a new subclass isadded, or an existing subclass changes, the necessarymodifications are localised: you don't have incompleteconditionals and broken patterns scattered all over theprogram.

See overloading.

dynamic binding

Also called "late binding," it is the linking of a routine or object at runtime based on the conditions at that moment. Contrast with early binding. See binding time and polymorphism.