Refactoring & Modernization
Target: Claude 3.7, Cursor, Windsurf, ChatGPT

God Class & Long Method Decomposition with Design Patterns

Decompose monolithic 1,000+ line classes into Single Responsibility components using SOLID design patterns.

Design PatternsSOLIDOOPRefactoringClean Architecture

Interactive Prompt Playground

Customize Template Fields
Live replacement
{{CODE}}
{{LANGUAGE}}
{{RESPONSIBILITIES}}
Rendered Prompt (Ready to paste)1393 characters
You are a Principal Software Architect and clean code authority.

Deconstruct this monolithic God Class into modular, Single Responsibility components adhering to SOLID principles:

God Class Code:
```
public class UserManager {
    // Handles user authentication, database persistence, invoice generation, 
    // PDF rendering, sending emails, and audit logging all in one 1200-line class.
    public void registerUser(...) { ... }
    public void generateInvoicePdf(...) { ... }
    public void sendResetPasswordEmail(...) { ... }
    public void logAuditSecurityEvent(...) { ... }
    public void exportToCsv(...) { ... }
}
```

Language & Framework: Java 21 with Spring Boot DI
Domain Responsibilities: Authentication, Stripe Billing, PDF rendering, Email dispatch, Audit logging

Provide an architectural decomposition:
1. **Responsibility Analysis (SRP Violations)**:
   - Group the methods and state into distinct domain concerns (e.g. Persistence, Business Rules, Notification, Formatting).
2. **Design Pattern Application**:
   - Recommend appropriate patterns (e.g. Factory, Strategy, Observer, Facade, Decorator) to decouple dependencies.
3. **Dependency Injection & Interface Contracts**:
   - Define clean interfaces for each extracted component.
4. **Refactored Codebase**:
   - Provide the complete code for the extracted interfaces, services, and the streamlined facade class.

How to Use This Prompt

  1. Paste your monolithic class.
  2. List the mixed responsibilities.
  3. Receive clean decoupled classes, interfaces, and dependency injection configs.

Engineering Tips & Best Practices

  • Keep the original class as a deprecated Facade delegating to the new services to avoid breaking existing callers.

What This Prompt Inspects

Key failure modes, design principles, and quality standards evaluated during execution.

Single Responsibility (SRP)

Splits classes so each component has only one reason to change.

Interface Segregation (ISP)

Clients depend only on minimal methods they actually call.

Facade Backward Compatibility

Preserves existing entry points via a thin delegating facade.

SprintKit Workflow Integrations

Complementary interactive tools and workflows across SprintKit to accelerate your engineering process.

Related Prompts

Explore related developer prompts in this workflow domain.

All Prompts

Legacy Code Safe Refactoring with Characterization Tests

Safely modernize fragile legacy codebases using Martin Fowler refactoring patterns and golden master tests.

RefactoringClean CodeDesign PatternsLegacy Code
3 variablesCustomize prompt

Microservices Boundary & Domain-Driven Design Decomposition

Deconstruct monoliths or complex systems into bounded contexts with clear domain events and data ownership.

MicroservicesDDDArchitectureSystem Design
2 variablesCustomize prompt

Spring Boot REST Service & JPA Code Review

Deep code review for Spring Boot services examining transaction boundaries, JPA N+1 queries, concurrency, and validation.

JavaSpring BootJPAHibernate+2
4 variablesCustomize prompt