13

If I create this method

public void foo()

And then I create an overloaded version like this

public void foo( string bar )

Do we say that the second functions overloads the first, or are both methods equally "overloaded"?

This would imply (I think), that there is a base type function, that is being overloaded, by another function (somewhat like inheritance, but not really).

Assuming that one method can "overload another", would also imply terms like "overloader" and "overloadie", if that is a word at all. But that doesn't feel right at all, especially since you can have several overloads.

I got to this question when I wanted to write down the process of creating an overloaded method and I wanted the most correct way of writing it down.

Examples:

  • I am overloading foo
  • I am overloading foo with foo( string bar )
  • I am creating an overloaded method
  • I am making foo overloaded

So yeah, this kind of got me thinking, I am not sure what to make of it. There are hundreds, if not thousands, of descriptions of function overloading online, but at a first glance I couldn't find any addressing this.

3
  • I would like to know why the word overload was used for this. It does not seem to make any sense. What is being loaded? How is it loaded again or excessively? Commented Sep 26, 2016 at 20:12
  • @MartinMaat Have you read the accepted answer by thiton and kindall's comment on it? They seem to do a good job of explaining what's being (over)loaded.
    – 8bittree
    Commented Sep 27, 2016 at 16:34
  • I have read those, they explain the concept, not the ethomology. Commented Sep 27, 2016 at 16:43

3 Answers 3

29

When talking about overloads, the name of the function is overloaded, not the function itself. The functions overloading the name are "overloads" and overload the name, but not each other. In your example, "public void foo()" and "public void foo( string bar )" both overload the name "foo". Therefore, you cannot speak in terms of overloader and overloadee of one of the functions, because they have no direct relationship.

In your examples, you can say that you are overloading "foo" (the name) with "foo( string bar )" (the function), but you cannot say that you create an overloaded method, because methods are never overloaded. You can say that you create an overloading method. To formulate "making foo overloaded" is just a worse way of saying "overload foo".

4
  • But would then not every function overload its name, even if no other function has the same one? Commented Apr 19, 2012 at 19:17
  • I agree with this as the answer to the general question above. But if one called one of the functions from the other, then I perceive a sense in which one overloaded the other. Commented Apr 19, 2012 at 21:00
  • 3
    @leftaroundabout: "Overloading" implies that you're doing more "loading" than usual, so the term is only used when you have more than one function with the same name.
    – kindall
    Commented Apr 19, 2012 at 21:36
  • Agreed with @kindall; the word "overload" in a software development context means "to assign more than one meaning to"; overloading columns in a DB (meaning depends on other fields), overloading parameters (meaning depends on other parameters), etc. One method doesn't overload any other, but if there is more than one method with one name, the name is "overloaded".
    – KutuluMike
    Commented Apr 20, 2012 at 0:22
15

I would simply say foo is overloaded. There is certainly no master/slave or parent/child relationship going on here.

2
  • 2
    Agree -- it's the name of the method or operator that's overloaded, not the method itself. Not to be confused with overriding, where the implementation of a given method in a subclass supplants the implementation in the parent class.
    – Caleb
    Commented Apr 19, 2012 at 16:52
  • 1
    I agree with this too, but i think thiton does a better job at explaining it. Thank you for your answer ! Commented Apr 19, 2012 at 16:56
3

I think that a good way to express this is to focus on the final result, not on changes made to the class over time. Thus, instead of saying "I overloaded 'foo' with 'foo(other parameters)'," you say "foo is an overloaded function, with 'foo()' and 'foo(other parameters).'"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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