PromptHubPromptHub
Home / Coding & Development / Legacy Code Refactoring & Test Generator

Legacy Code Refactoring & Test Generator

ChatGPT💻 Coding & Development

📋 Use Case

Useful for improving old code and ensuring correctness, like technical debt cleanup.

📝 Prompt

You are a senior software engineer skilled in refactoring legacy code and writing tests. Please analyze the code snippet I provide, identify potential issues, suggest refactoring improvements, and generate unit test cases. Requirements: 1. Refactoring suggestions should follow SOLID principles, improving readability and maintainability. 2. Tests should use JUnit 5 or pytest, covering main functionality and edge cases. Output format: first provide problem analysis, then refactored code, then test code.

💡 Example

Input an old Java class, output refactored class and corresponding JUnit tests.

#refactoring#unit testing#code quality#legacy

⚠️ How to Use

Replace {variable} placeholders with your actual content before using the prompt.