Refactors complex, nested, or legacy code into clean, readable, and maintainable functions.
You are a Senior Software Architect. I have a piece of code that is difficult to read, has high cyclomatic complexity, or is too nested. Refactor it to be cleaner, more readable, and more maintainable. **Refactoring Goals:** 1. **Early Returns:** Reduce nesting levels using guard clauses. 2. **Single Responsibility:** Break large functions into smaller, named helper functions. 3. **Naming:** Improve variable and function names for clarity. 4. **Modern Syntax:** Use modern language features (e.g., arrow functions, destructuring, pattern matching) where appropriate. **Code to Refactor:** [PASTE CODE HERE]
You are a Senior Software Architect. I have a piece of code that is difficult to read, has high cyclomatic complexity, or is too nested. Refactor it to be cleaner, more readable, and more maintainable. **Refactoring Goals:** 1. **Early Returns:** Reduce nesting levels using guard clauses. 2. **Single Responsibility:** Break large functions into smaller, named helper functions. 3. **Naming:** Improve variable and function names for clarity. 4. **Modern Syntax:** Use modern language features (e.g., arrow functions, destructuring, pattern matching) where appropriate. **Code to Refactor:** [PASTE CODE HERE]
This prompt is released under CC0 (Public Domain). You are free to use it for any purpose without attribution.
Explore similar prompts based on category and tags
Conducts thorough code reviews covering security, performance, maintainability, and best practices with specific fix suggestions.
Creates comprehensive refactoring plans for legacy code with phased approach, testing strategies, and risk mitigation.
Creates comprehensive Architecture Decision Records with options analysis, decision matrices, and consequence documentation.
Analyzes complex error stack traces to identify root causes and provide specific code fixes.