Relative Content

Tag Archive for method-overloading

what’s the point of method overloading? [duplicate]

This question already has answers here: When is method overloading appropriate? (3 answers) What’s the difference between overloading a method and overriding it in Java? (4 answers) Closed 9 years ago. I am following a textbook in which I have just come across method overloading. It briefly described method overloading as: when the same method […]

what’s the point of method overloading? [duplicate]

This question already has answers here: When is method overloading appropriate? (3 answers) What’s the difference between overloading a method and overriding it in Java? (4 answers) Closed 9 years ago. I am following a textbook in which I have just come across method overloading. It briefly described method overloading as: when the same method […]

Overloading methods that do logically different things, does this break any major principles?

This is something that’s been bugging me for a bit now. In some cases you see code that is a series of overloads, but when you look at the actual implementation you realize they do logically different things. However writing them as overloads allows the caller to ignore this and get the same end result. But would it be more sound to name the methods more explicitly then to write them as overloads?

Overloading methods that do logically different things, does this break any major principles?

This is something that’s been bugging me for a bit now. In some cases you see code that is a series of overloads, but when you look at the actual implementation you realize they do logically different things. However writing them as overloads allows the caller to ignore this and get the same end result. But would it be more sound to name the methods more explicitly then to write them as overloads?

Overloading methods that do logically different things, does this break any major principles?

This is something that’s been bugging me for a bit now. In some cases you see code that is a series of overloads, but when you look at the actual implementation you realize they do logically different things. However writing them as overloads allows the caller to ignore this and get the same end result. But would it be more sound to name the methods more explicitly then to write them as overloads?