I am writing a method that is part of the public interface of the Java class. On the whole, it allows the caller to specify values for assignment to several database entities - therefore, they must provide both identifiers of the objects themselves and values for their assignment.
I am trying to implement this as List<Pair<Integer, Integer>>or only two arguments List<Integer>. Both will obviously work, and none of them will cause any problems with implementation or efficiency in my method. This is basically the same information anyway (2xn array), just alternating in different ways.
So, I would like some opinions on what you think would be better, and why.
The advantages that I see so far for the list of pairs:
- More accurately reflects the actual relationship between objects
- Eliminates some dynamic error classes (for example, inconsistent list lengths)
Benefits for a pair of lists:
- Does not rely on any classes other than the JDK (just as it
Pairshould be understood as a concept) - It does not require the creation of any auxiliary objects for transferring data around
- Callers most often have arguments in separate lists, so they don’t need to rebuild the data before calling the method
, (, , - , ). , Integer, - PrimaryKey, , .
, - objectId . , . , , .