Single Responsibility
-
Single Responsibility Principlepython/SOLID 2023. 12. 5. 20:11
정의 Things should have only one reason to change. Mixing Resposibility 유형 위반 코드 class Employee: xml_filename = "emp.xml" def __init__(self, name, salary): self.name = name self.salary = salary def raise_salary(self, factor): return self.salary * factor def save_as_xml(self): with open(self.xml_filename, "w") as file: file.write(f"{self.name}") 위의 Employee 클래스는 business logic (raise_salary) 와 stor..