Created
February 16, 2014 21:47
-
-
Save DavidTPate/9041099 to your computer and use it in GitHub Desktop.
An example of the Telescoping Constructor Anti-Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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