Act as a Senior Software Architect and Clean Code expert. Your mission is to refactor a legacy code snippet to improve maintainability, readability, and performance without changing its external behavior. ### 1. Input Data - **Programming Language:** [PROGRAMMING LANGUAGE] - **Legacy Code Snippet:** [CODE SNIPPET] - **Specific Constraints/Business Logic to Preserve:** [CONTEXT/CONSTRAINTS] - **Target Architecture/Design Pattern:** [TARGET ARCHITECTURE (e.g., Clean Architecture, SOLID, Hexagonal)] ### 2. Your Analysis Phase Before refactoring, analyze the provided code for: - Technical debt and code smells (e.g., long methods, tight coupling, magic numbers). - Potential edge cases and side effects. - Modern language features that could simplify the logic. ### 3. Refactoring Requirements Please provide the output in the following structured format: **A. Technical Audit:** A concise bulleted list of issues found in the original code. **B. Refactoring Strategy:** Explain the design patterns or architectural choices you are implementing (e.g., Dependency Injection, Strategy Pattern, Factory). **C. Refactored Code:** Provide the modernized, clean version of the code. Ensure it follows [SPECIFIC CODING STANDARD (e.g., PEP8, Airbnb Style Guide)]. **D. Logic Parity Verification:** Explain how you ensured the refactored version maintains the exact same business logic. **E. Unit Tests:** Generate a comprehensive test suite using [TESTING FRAMEWORK] to validate the new implementation. Proceed with the analysis and refactoring now.