When faced with a class that has multiple similar methods operating on different parameter types, do you include some kind of description of the parameters in the method name, or do you keep the name the same and trust that the parameters themselves provide enough information? Contrast the two examples given below:
interface Option1 {
update(ObjectA);
update(ObjectB);
update(List<Object>);
}
interface Option2 {
updateA(ObjectA);
updateB(ObjectB);
updateAll(List<Object>);
}
I've heard the following arguments:
- Option 1 is better as it does not contain redundant information
- Option 2 is better as the code is more readable and easier to maintain