Assume that we have a class with multiple constructors which may look like the following:
public class C
{
private String id;
private int a;
private int b;
private int c;
C(String id, int a){}
C(String id, int a, int b){}
C(String id, int a, int b, int c){}
C(C[] cs){}
// This method will be used to print objects created by C(String id, int a)
public void printC1() {}
// This method will be used to print objects created by C(String id, int a, int b)
public void printC2() {}
// This method will be used to print objects created by C(String id, int a, int b, int c)
public void printC3() {}
}
The methods printC1, printC2, printC3 have a lot of similarities. Could anyone support me with some hints how I should redefine the class C in order to follow design principles like DRY, ...
printmethod. Try to encapsulate and hide as many decisions as possible from your user. This is not an answer because your question does not fit within the spirit of CodeReview. \$\endgroup\$