How to design constructors?
Lets assume a class Foo with 2 instance variables, int x and int y. The
use case demands I can construct the class with either none, single or all
params.
input X input Y
0 0 no constuctor
0 1 public Foo(int x);
1 0 public Foo(int y);
1 1 public Foo(int x, int y);
Now whats the convention/best practices in this case. Do I need to add all
the permutations of constructors ? If yes, the it would result in
exponential growth. If No, then whats solution ?
No comments:
Post a Comment