Late binding is a computer programming mechanism in which the method being called upon an object is looked up by name at runtime. This is informally known as duck typing or name binding.
Late binding is often confused with dynamic dispatch, but there are significant differences. With early binding the compiler statically verifies that there are one or more methods with the appropriate method name and signature. This is usually stored in the compiled program as an offset in a virtual method table ("v-table") and is very efficient. With late binding the compiler does not have enough information to verify the method even exists, let alone bind to its particular slot on the v-table. Instead the method is looked up by name at runtime.
The primary advantage of using late binding in Component Object Model (COM) programming is that it does not require the compiler to reference the libraries that contain the object at compile time. This makes the compilation process more resistant to version conflicts, in which the class's v-table may be accidentally modified. (This is not a concern in JIT-compiled platforms such as .NET or Java, because the v-table is created by the secondary compiler against the libraries as they are being loaded into the running application.)
... Runtime (dynamic) binding Java C# Late-bound (dynamic) type No Yes. ...
... Late binding has poorer performance than an early bound method call ... Late binding necessarily prevents the use of static type checking ... When making a late bound call, the compiler has to assume that the method exists ...
... Since Smalltalk has a late bound execution model, and since it provides objects the ability to handle messages that are not understood, it is possible to go ahead and ...
Famous quotes containing the words binding and/or late:
“What is lawful is not binding only on some and not binding on others. Lawfulness extends everywhere, through the wide-ruling air and the boundless light of the sky.”
—Empedocles 484424 B.C., Greek philosopher. The Presocratics, p. 142, ed. Philip Wheelwright, The Bobbs-Merrill Co., Inc. (1960)
“I date the end of the old republic and the birth of the empire to the invention, in the late thirties, of air conditioning. Before air conditioning, Washington was deserted from mid-June to September.... But after air conditioning and the Second World War arrived, more or less at the same time, Congress sits and sits while the presidentsor at least their staffsnever stop making mischief.”
—Gore Vidal (b. 1925)