I have a couple of methods that look like this:
public void do(A a, B b);
public void do(A A, C c);
public void do(D d, A a);
public void do(D d, E e, X x, F f, Optional<A> a);
And so on, there are about a dozens method that does basically the same but with varying parameters.
Now I thought about using a builder pattern that would allow me to use the functionality like this:
withA(a).withB(b).withX(x).do();
However, the problem is that one of the dozens of methods throws an exception. If I use a builder pattern, then do() will have to throw this exception and therefore all clients will have to handle it. In my opinion, this sounds like a problem.
My question:
- Is this a problem?
- If it is, how can it be avoided?