Let's suppose you've got a class defined (in pseudocode):

class Puppy {
    // ...
    string sound = "Rawr!";

    void bark() {

And say, given a Puppy instance, you call it's bark() method:

int main() {
    Puppy p;

Notice how bark() uses the member variable sound. In many contexts, I've seen folks describe sound as the member variable of the "calling object."

My question is, what's a better term to use than "calling object"?

To me, the object is not doing any calling. We know that member functions are in a way just functions with an implicit this or self parameter.

I've come up with "receiving object" or "message recipient" which makes sense if you're down with the "messaging" paradigm.

Do any of you happy hackers have a term that you like to use?

I feel it should mean "the object upon which a method is called" and TOUWAMIC just doesn't cut it.

As for who the "caller" is, I would say that main instantiates a Puppy object and calls its bark() method.

  • Honestly you got me thinking there - I came up with "The responding object" - in line with "real life objects" – yati sagade Nov 15 '11 at 19:15
  • Do you want a name for P in the context of method calls, or the name of the inverse relationship to member variable? Or the name of the inverse relationship to member variable in the context of method calls? – psr Nov 15 '11 at 20:51
  • The caller is calling the callee. Later on, you can say the callee was called. I think you have a calling object and a called object. – Hand-E-Food Nov 15 '11 at 22:10
  • @Hand-E-Food: I'm not sure what you mean, I never said that p was called or that the callee was called. Objects are never "called" nor do they "call" per se. – ybakos Nov 17 '11 at 12:54
  • 1
    @ybakos Your most recent edit now tells us who the caller is -- it is the function main(). Since your title question asks for a name for the "calling object", it's interesting that you chose to call p.bark() from a function that doesn't belong to any class. Given that, could you restate your question so that we can figure out what you're really asking about? – Caleb Nov 17 '11 at 15:15

Using the word object in the reference is redundant.

Perhaps caller and callee is simplistic enough. Referring to the actual object as an instance of type is also another approach as noted by Wyatt; instance of Puppy or if being succinct is the goal...instance.

| improve this answer | |
  • +1, for the clarified version I'd use 'caller' in most contexts. – Wyatt Barnett Nov 15 '11 at 19:22
  • 5
    I may be wrong, but I think "caller" is the object that invokes some method on p – yati sagade Nov 15 '11 at 19:22
  • Well, not the object that invokes the method, but the scope within which the function in which the object's method is invoked, no? (eg, main above invokes p's bark() method.) – ybakos Nov 17 '11 at 12:59
  • "Caller" and "callee" conventionally refer to (member) functions, not objects. Puppy::bark() is the caller; the callee print() apparently is a non-member function. – MSalters Nov 17 '11 at 15:49

p is the receiver, recipient, target, callee, "the puppy," or just "p".

The object sending the message/calling the method is the sender or caller. Caller can also mean the function or method calling p.bark().

Sometimes the relationship between the objects is used instead because that's an easier way to identify the two, so one might be the parent and the other the child, or one might be the delegate and the other the delegator.

| improve this answer | |
  • I do like "callee." – ybakos Nov 15 '11 at 23:50
  • "The object sending the message/calling the method is the sender or caller. Caller can also mean the function or method calling p.bark()." -- I agree with the second sentence, but not the first, if by 'object sending the message' you mean p above. p isn't doing the calling. – ybakos Nov 17 '11 at 2:04
  • @ybakos No, p is the recipient/callee in the example. It might be the case that p is also the caller, but I wasn't assuming that and your example doesn't tell us anything about where the code that calls p.bark() lives. – Caleb Nov 17 '11 at 3:13

I'd go with any of:

  • call target
  • method owner (although this doesn't really make sense if p is null, because then it hardly owns anything)
  • callee

Although in that very context, I'd go with p ;)

| improve this answer | |

I'd generally call p an instance of Puppy, not the calling object

| improve this answer | |
  • Thanks for the response, but I've edited the question a bit to provide more context. I'm not so concerned about how to describe what p is itself (I agree, it's an instance of the class). Rather, how to describe p in the context of method calls. – ybakos Nov 15 '11 at 19:19

Based on your comment in Wyatt's post:

Rather, how to describe p in the context of method calls.

I'd have to go with describing p in the context of method calls as being the "method's instance".

In object-oriented programming, a method is a subroutine (or procedure or function) associated with a class. [Wikipedia]

As such, when describing the inverse relationship, I would believe that "method's instance" would be correct your described context (but exchanging class for instance as we're describing the relationship to the instance, not the class definition itself).

| improve this answer | |

The "Calling Object" is roughly equivalent to a dispatcher, so I guess you could use that term to describe it.

Methods are bound to a class, so "Calling Object" is redundant as Aaron points out.

Usually I think of "the Caller" as some code or object outside of the bound method.

Say I have a form called form1 and I create a instance of Puppy. From form1 I called p.bark(). I would see the Calling object is form1.

I don't think there is a 100% correct answer here.

| improve this answer | |
  • "Usually I think of 'the caller' as some code or object outside of the bound method." Exactly. To me, the "caller" is the scope within which the method is called. – ybakos Nov 17 '11 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.