Skip to content

Latest commit

 

History

History
12 lines (9 loc) · 406 Bytes

2_OCP_code_refactor.md

File metadata and controls

12 lines (9 loc) · 406 Bytes

refactor Customer class to follow the OCP

class Customer {
  int GetDiscount { return 10; }
}
class GoldCustomer : Customer {
  int GetDiscount { return 50; }
}

Then in future when we need to cater for a new CustomerType, we simply add a new CustomerTYPE class. All existing code remains unchanged. All existing tests continue to pass.

« back to readme.md