How bad is it to have two methods with the same name but different signatures in two classes?
- by Super User
I have a design problem related to a public interface, the names of methods, and the understanding of my API and code.
I have two classes like this:
class A:
...
function collision(self):
....
...
class B:
....
function _collision(self, another_object, l, r, t, b):
....
The first class has one public method named collision, and the second has one private method called _collision. The two methods differs in argument type and number.
As an example let's say that _collision checks if the object is colliding with another object with certain conditions l, r, t, b (collide on the left side, right side, etc) and returns true or false. The public collision method, on the other hand, resolves all the collisions of the object with other objects.
The two methods have the same name because I think it's better to avoid overloading the design with different names for methods that do almost the same thing, but in distinct contexts and classes.
Is this clear enough to the reader or I should change the method's name?