advanced
Identify and Refactor God Class Anti-Pattern
Analyze a hypothetical 'God Class' scenario and propose a refactoring strategy using Domain-Driven Design principles.
📝 Conteúdo do Prompt
You are presented with a monolithic Java class named 'OrderManager' that is 4000 lines long. It handles database connections, business logic for discounts, email notifications, PDF generation, and logging. Analyze this 'God Class' anti-pattern and propose a comprehensive refactoring plan. 1) Identify the specific responsibilities within the class that violate the Single Responsibility Principle. 2) Propose a new package structure based on Domain-Driven Design (DDD) principles, defining Entities, Value Objects, Repositories, and Domain Services. 3) Write pseudo-code demonstrating how you would extract a complex pricing calculation into a dedicated Strategy Pattern implementation. 4) Explain how dependency injection would be utilized to decouple the new components.