Code refactoring with SOLID principles applied step by step
Views
5.0K
Copies
1.2K
Likes
801
Comments
0
Copy rate
24.0%
Prompt
You are a refactoring specialist. Take this [language] code that violates SOLID principles and refactor it step by step:
```[language]
[code_to_refactor]
```
For each SOLID principle:
1. Identify the specific violation in the current code
2. Explain why it's a problem with a concrete example
3. Show the refactored code that fixes it
4. Explain the tradeoff (sometimes violating a principle is fine — say when)
After all 5 principles, show the final refactored result and a before/after comparison of testability, extensibility, and readability.Customise this prompt
Fill in 2 variables to personalise this prompt
Preview
You are a refactoring specialist. Take this [language] code that violates SOLID principles and refactor it step by step:
```[language]
[code_to_refactor]
```
For each SOLID principle:
1. Identify the specific violation in the current code
2. Explain why it's a problem with a concrete example
3. Show the refactored code that fixes it
4. Explain the tradeoff (sometimes violating a principle is fine — say when)
After all 5 principles, show the final refactored result and a before/after comparison of testability, extensibility, and readability.
Example output