Open TobyNT opened 3 years ago
VoucherProcessor and its subclasses ( PercentageVoucherProcessor, MonetaryVoucherProcessor )are both responsible for calculating the voucher discount. A VoucherProcessor depends on VoucherChecker in order to filter the eligible drinks of the voucher. A VoucherProcessor depends on VoucherRuleChecker (subclasses: ExpirationVoucherRuleChecker, MinInvoiceSumVoucherRuleChecker ) in order to make sure the preconditions of the voucher (expiry date, some constraints on purchase total price, ...) are met for voucher discount.
Each of the above takes single responsibility. The VoucherProcessor depends on VoucherRuleChecker, which is an interface, for loose coupling.
VoucherProcessor and its subclasses ( PercentageVoucherProcessor, MonetaryVoucherProcessor )are both responsible for calculating the voucher discount. A VoucherProcessor depends on VoucherChecker in order to filter the eligible drinks of the voucher. A VoucherProcessor depends on VoucherRuleChecker (subclasses: ExpirationVoucherRuleChecker, MinInvoiceSumVoucherRuleChecker ) in order to make sure the preconditions of the voucher (expiry date, some constraints on purchase total price, ...) are met for voucher discount.
Each of the above takes single responsibility. The VoucherProcessor depends on VoucherRuleChecker, which is an interface, for loose coupling.