CEN206 Object-Oriented Programming
Builder - The Problem (Telescoping Constructor)
There is another approach that does not involve breeding subclasses. You can create a giant constructor right in the base House class with all possible parameters that control the house object.
class House {
House(int windows, int doors, int rooms,
boolean hasGarage, boolean hasSwimPool,
boolean hasStatues, boolean hasGarden,
boolean hasYard, boolean hasFence) {
}
}
new House(4, 2, 5, true, false, false, true, true, false);
In most cases, most of the parameters will be unused, making the constructor calls pretty ugly.