32 lines
946 B
Markdown
32 lines
946 B
Markdown
Refactor the specified code to improve quality and maintainability. Focus on:
|
|
|
|
1. **Code Structure**
|
|
- Extract complex methods/functions
|
|
- Reduce function/method length
|
|
- Separate concerns appropriately
|
|
- Apply SOLID principles
|
|
|
|
2. **Code Quality**
|
|
- Remove code duplication (DRY)
|
|
- Improve naming for clarity
|
|
- Simplify complex conditionals
|
|
- Replace magic numbers with constants
|
|
|
|
3. **Design Patterns**
|
|
- Identify applicable design patterns
|
|
- Suggest pattern implementations
|
|
- Improve abstraction levels
|
|
|
|
4. **Maintainability**
|
|
- Reduce cyclomatic complexity
|
|
- Improve testability
|
|
- Enhance readability
|
|
- Add appropriate comments for complex logic
|
|
|
|
5. **Backward Compatibility**
|
|
- Ensure existing functionality is preserved
|
|
- Maintain existing test coverage
|
|
- Document any breaking changes
|
|
|
|
Provide before/after code examples with clear explanations of the improvements and their benefits.
|