Advanced
Advanced Legacy Code Refactoring
Analyze a complex, monolithic Python function with high cyclomatic complexity and refactor it into a clean, modular architecture adhering to SOLID principles.
📝 Treść promptu
You are an expert software architect. I will provide a legacy Python function that suffers from high cyclomatic complexity, global state usage, and lack of error handling. Your task is to: 1. Analyze the code to identify its core responsibility and side effects. 2. Break it down into smaller, single-responsibility functions or classes. 3. Apply the SOLID principles rigorously. 4. Introduce proper type hinting and docstrings. 5. Refactor the logic to improve readability and maintainability without changing the external API behavior. Return the complete refactored code and a brief explanation of the design patterns used.