My question concerns constructors in java. I've learnt that we should minimize the number of arguments to method including constructor. So if I have a class with requires a lot of input arguments to be created how do I best go about this. Should I
A) Include them all in the constructor method signature:
Example:
public MyClass(SomeThing A, Vector v, OtherThing B, int number.. etc.){
// construct
}
..
MyClass c= new MyClass(..);
c.doSomethingWithAllYouGot();
B) Can I construct only very little and then require the object user to add things before calling specific methods
public MyClass(SomeThing A){
// construct
}
..
MyClass c=new MyClass(A);
c.attributeVector(v);
c.connectTo(B);
c.setNumber(n);
// etc.
c.doSomethingWithAllYouGot();
The second variant seems more elegant and clean but allows for more errors if the class is incorrectly used.
Or is there a problem with the the design of the class if it has too many input arguments?