I am developing a converter from objects of different domains, which accepts both, converting one object to other, or a list to another list.Please consider the following example:public MyObject2 decode(MyObject1 originalObject) {    String name = String.valueOf(originalObject.getId());    return MyObject2(name);}public List<MyObject2> decodeList(Collection<MyObject1> originalObjectsList) {    return originalObjectsList.stream().map(this::decode).collect(Collectors.toList());}My situation much more complex than this, but for the sake of argument this is enough.At my team, we came with the doubt of what should be better in terms of Software Design and future understanding of the code. Prefer the method decodeList() with this exactly signature, or change it to overload decode().For me is difficult to say, because both look right. Overloading looks cleaner, but decodeList() also makes sense to me if you consider that repeating the same process multiple times deserves to be treated as different thing.Is there any best practices related to this kind of situation?
Repeating a process can be a situation for method overloading?
java
caveat/excuse for potentially stupid answer: I C#.To overload or not to overload that is...  not the question. Overloading is fine here but for future understanding of the code I suggest the question is class design. I'd want to see the functionality in one place.I don't know where the above methods are but I wonder if they could both be in the same class. Perhaps a generic collection class.public class ObjectCollectionConverter<T, V> {    public T decodeObject (V originalObject) {}    public V decodeObject (T originalObject) {}    public List<V> decodeList(Collection<T> (originalObjectList)    public List<T> decodeList(Collection<V> (originalObjectList)}// The above could be static I suppose, in which case// the class name might be `ObjectConverter`Remove the decode from the Objectn class. This is good in terms of Single Responsibility Principle.The above seems good if there is a strong relationship / correlation in business domain terms between these two, or any two, Objectn classes.Depending on your requirements/domain the class and/or methods could be static.This converter class suggests an interface may be in order to guarantee the presence of decode method. But if we're talking only about Object1 and Object2 classes then it is not necessary.You might define a delegate for the decode method which could allow more flexibility, And an interface would not be necessary in this case.Class composition flexibility. 