I have a method with the following signature: foo (Sample sample, Aliquot aliquot)
"foo" needs to alter a Sample object, either the first argument or from the second argument it can extract its Sample. For example:
foo (Sample sample, Aliquot aliquot) {
Sample out = null;
if (sample != null)
out = sample
else
out = aliquot.getSample()
return out;
}
But that is so un-elegant, other than reading the API a developer does not know the reference of the first argument overrides the Sample of the second argument.
Now, I could change "foo" to foo (SomeMagicalObject bar) where SomeMagicalObject is a tuple for Sample and Aliquot and holds some logic ... etc.
But I am wondering, are there some patterns for this question?