1

Compare

void doSomething(A a, B b, C c, D d);
void doSomething(A a, B b, C c, D d, E e);

with

void doSomething(A a, B b, C c, D d, Optional<E> e);

which one is a better practice and why?

Fermat's Little Student
  • 5,549
  • 7
  • 49
  • 70
  • 4
    The second version sounds incredibly awkward to use. – user2357112 Aug 05 '16 at 16:43
  • really depends on how different the implementation is when E is involved. If the implementation is super similiar you could make `void doSomething(A a, B b, C c, D d, Optional e);` and ALSO overload the two versions, and just have them call the method with the optional. It really depends – dustinroepsch Aug 05 '16 at 16:45
  • 1
    When it's about deciding about Optional or not, think about DRY. – xenteros Aug 05 '16 at 16:46

0 Answers0