medium
Legacy Code Refactoring
Refactor a legacy code snippet to follow modern design patterns.
📝 Conteúdo do Prompt
Analyze the following hypothetical legacy Java method (describe it as a monolithic 200-line method handling HTTP requests, parsing XML, querying a database via raw JDBC, and formatting HTML responses). Refactor this code into a clean architecture using the Strategy and Factory patterns. Separate concerns into distinct classes for Request Handling, Data Parsing, Database Access, and Response Formatting. Include the Java code for the refactored solution and a brief explanation of how the Single Responsibility Principle and Open/Closed Principle are applied in your new design.