open closed
-
Open-closed Principlepython/SOLID 2023. 12. 6. 20:27
정의 Open for extension but closed for modification. 위반 코드 class Employee: def __init__(self, name): self.name = name class Manager(Employee): def __init__(self, name, department): super().__init__(name) self.department = department def print_employee(e): if type(e) is Employee: print(f"{e.name} is an employee") elif type(e) is Manager: print(f"{e.name} leads department {e.department}") print_empl..