Code design question for Java or Java-like languages (excluding languages which support default values for method parameters such as Javascript flavors):
You would like to implement a method with the following features:
- Take N parameters, for some reasonably large but finite value of N (like N > 2).
- O(N) of those parameters (as in, the vast majority of those parameters) are optional.
- In this case, "optional" means that the method should not error out if the parameters in question are not present. Altering the functionality of the process in some way may be possible. As an example, let's say our method takes (first, middle, last) of a name and prints the name. In this case, we can model the middle name as an "optional" parameter by directly not printing the middle name if it's not present.
- I don't want a solution that uses a List nor a VarArgs without a good explanation of why it's better.
I want to optimize the answer to this question for scalability; as the number of optional parameters increases, I would prefer if the code for my class remained clean and maintainable.