Skip to content

Instantly share code, notes, and snippets.

@DavidTPate
Created February 16, 2014 21:47
Show Gist options
  • Select an option

  • Save DavidTPate/9041099 to your computer and use it in GitHub Desktop.

Select an option

Save DavidTPate/9041099 to your computer and use it in GitHub Desktop.
An example of the Telescoping Constructor Anti-Pattern
public class Car {
int year;
String make;
String model;
String carType;
public Car(int year) {
this.year = year;
}
public Car(int year, String make) {
this.year = year;
this.make = make;
}
public Car(int year, String make, String model) {
this.year = year;
this.make = make;
this.model = model;
}
public Car(int year, String make, String model, String carType) {
this.year = year;
this.make = make;
this.model = model;
this.carType = carType;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment