Robert

41%
Flag icon
// The strategy enum pattern enum PayrollDay {     MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY,     SATURDAY(PayType.WEEKEND), SUNDAY(PayType.WEEKEND);     private final PayType payType;     PayrollDay(PayType payType) { this.payType = payType; }     PayrollDay() { this(PayType.WEEKDAY); }  // Default
Robert
This use of default constructor is hardly less error-prone than the previous example: one can just as easily add HOLIDAY and unintentionally inherit the default strategy.
Effective Java
Rate this book
Clear rating
Open Preview