Questions tagged [late-binding]

Late binding is a mechanism in which the method being called upon an object is looked up by name at runtime.

Late binding is a mechanism in which the method being called upon an object is looked up by name at runtime.

The specific type of a late bound object is unknown to the compiler at compile time. This is contrasted with early binding, where relationships between objects, methods are properties are established during compile time.

It is expected that questions tagged specifically relate to programming using late bound code. You should also tag your post with the specific programming language being used.

Example (VBA):

' late bound objects are declared As Object
Dim obj As Object
Set obj = CreateObject("Excel.Application")

Related Tags:

353 questions
8
votes
1 answer

Invoking System.Delegate class object in C#

I am trying to build an object that uses System.ComponentModel.ISynchronizeInvoke, which has the method: (amongst others) public object Invoke(Delegate method, object[] args) What is the best way to call the method with the given arguments? I…
Rob
  • 1,687
  • 3
  • 22
  • 34
7
votes
3 answers

Is Fragile Base Class the only reason why "inheritance breaks encapsulation"?

As the Gang of Four states it in "Design Patterns": "it's often said that 'inheritance breaks encapsulation'", paraphrasing Snyder in "Encapsulation and Inheritance in Object-Oriented Programming Languages". However, each time I read that…
7
votes
1 answer

Why not use early binding when possible?

I read an example about polymorphism which looks like bellow, where show() is a virtual function: int main() { Derived dv1; Derived dv2; Base* ptr; ptr = &dv1; ptr->show(); ptr = &dv2; ptr->show(); } The books say that in this case,…
Stoatman
  • 758
  • 3
  • 9
  • 22
7
votes
3 answers

How do I check enum property when the property is obtained from dynamic in C#?

Suppose I know that property Color of an object returns an enumeration that looks like this one: enum ColorEnum { Red, Green, Blue }; and I want to check that a specific object of unknown type (that I know has Color property) has Color set…
sharptooth
  • 167,383
  • 100
  • 513
  • 979
7
votes
1 answer

PHP __DIR__ evaluated runtime (late binding)?

Is it somehow possible to get the location of PHP file, evaluated at runtime? I am seeking something similar to the magic constant __DIR__, but evaluated at runtime, as a late binding. Similar difference with self and static: __DIR__ ~ self ??? …
Pavel S.
  • 11,892
  • 18
  • 75
  • 113
7
votes
1 answer

How to find out a COM prog id?

I'd like to access a COM library via late binding. How can I find out its progID? Type oClassType = Type.GetTypeFromProgID("THE MISSING PROGID");
Marc
  • 9,012
  • 13
  • 57
  • 72
6
votes
5 answers

Difference between Reflection and Late Binding in java with real time examples

While studying Java tutorials, Reflection and Late Binding have confused me. In some tutorials, they have written that they are both the same, and that there isn't any difference between Reflection and Late Binding. But other tutorials say that…
Kanika
  • 10,648
  • 18
  • 61
  • 81
6
votes
2 answers

Createinstance() - Am I doing this right?

I'm trying to put together a plugins system with .NET, and I'm not sure if I'm doing it correctly. The basis of the system is that a specific directory ({apppath}/Plugins/) will have a bunch of precompiled DLLs, and I want to look through each one…
Sukasa
  • 1,700
  • 4
  • 22
  • 40
6
votes
2 answers

What does "late-bound access to the destination object" mean?

The docs for Interlocked.Exchange contain the following remark: This method overload is preferable to the Exchange(Object, Object) method overload, because the latter requires late-bound access to the destination object. I am quite bewildered…
Benjamin Hodgson
  • 42,952
  • 15
  • 108
  • 157
6
votes
1 answer

Why is Spliterators.spliteratorUnknownSize() not late-binding?

I read up on spliterators today and implemented one using Spliterators.spliteratorUnknownSize(iterator(), Spliterator.NONNULL). According to spliteratorUnknownSize()'s documentation The [resulting] spliterator is not late-binding Being new to…
dotwin
  • 1,302
  • 2
  • 11
  • 31
6
votes
1 answer

Late Binding & Type Issues In VB

I'm trying to run my code which was originally created using Visual Studio through another application where late bindings are disallowed and this option cannot be altered unfortunately. I am very new to programming in general and struggling to get…
6
votes
1 answer

Late Binding to dll based on CPU architecture

I am currently writing a helper library that connects to shop floor PLCs via Software Toolbox's TopServer. The TopServer library has separate versions for x86 and x64 architectures and I want to load the appropriate version at runtime using late…
Phil Murray
  • 6,396
  • 9
  • 45
  • 95
6
votes
1 answer

phpDoc notation to specify return type identical to parameter type

Imagine the following hypothetical class structure, not an all too uncommon scenario with all PHPdoc hinting set up correctly: class BaseFilter { /** ...base methods... */ } class TextFilter extends BaseFilter { public function…
Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136
5
votes
1 answer

Is overriding toString() considered polymorphism?

I was having an exam in Java today and the examiner asked me if I can provide any examples of using polymorphism in my Spring Boot project. As I couldn`t think of anything at first, he pointed out that I have overriden toString() in my models and…
Petar Bivolarski
  • 1,599
  • 10
  • 19
5
votes
1 answer

lazy evaluation and late binding of python?

when is lazy evaluation? (generator, if, iterator?), when is late binding? (closure, regular functions?) a = [1,2,3,4] b = [lambda y: x for x in a] c = (lambda y: x for x in a) #lazy evaluation d = map(lambda m: lambda y:m, a)…
QuantumEnergy
  • 396
  • 1
  • 14
1 2
3
23 24