public class Foo{
private String a;
private int b;
public Foo(Foo foo){
this.a = foo.a;
this.b = foo.b;
}
}
Hi everyone.
I had this code in a small part I did at work.. My colleague saw this and gave me the "you-don't-deserve-to-breathe" look and went out for about 30 minutes to calm down. (I'm a fresh grad)
I've been trying to find out what is the shameful mistake I've made.. It was not successful.
Will somebody please explain exactly why is it a bad practice (or idiotic) to have this?
The reason I did this was that the class had many params, and I didn't want to have like 3 lines of parameters being passed (using primitive parameters) every time I needed to initialize this object.
And, FYI this object is (as we call it in work) a transaction object which is initialized whenever we need to pass around an entity class (it used instead of an entity class).
I do have a default constructor as well.
Thanks!