Advanced
Monolith to Modular Refactor
Refactor a legacy procedural code block into a modern, object-oriented structure utilizing SOLID principles.
📝 Contenu du Prompt
Analyze the following legacy code snippet (simulated: a 500-line script processing CSV data and sending emails). Refactor this logic into a modern, object-oriented architecture in Python. Apply SOLID principles strictly: 1) Use the Single Responsibility Principle to separate data parsing, validation, and notification logic into distinct classes. 2) Implement Dependency Injection for the email service to allow for easy mocking or swapping. 3) Use the Interface Segregation Principle to define contracts for data processors. 4) Explain your refactoring choices and how they improve testability and maintainability compared to the original monolithic function.