PromptsVault AI is thinking...
Searching the best prompts from our community
Searching the best prompts from our community
Prompts matching the #code-quality tag
Refactor code safely and effectively. Common refactorings: 1. Extract Method (long function → smaller functions). 2. Rename Variable (unclear → descriptive). 3. Extract Class (large class → multiple focused classes). 4. Inline Method (unnecessary abstraction). 5. Replace Magic Numbers with Constants. 6. Introduce Parameter Object (long parameter lists). 7. Replace Conditional with Polymorphism. When to refactor: before adding features, during code review, when fixing bugs. Red-Green-Refactor cycle. Use IDE refactoring tools. Keep tests green. Small steps. Commit after each refactoring. Based on Martin Fowler's 'Refactoring' book.
Balance new features with technical debt reduction effectively. Technical debt assessment: 1. Code quality metrics: cyclomatic complexity, test coverage, duplication. 2. Performance impact: page load times, API response times. 3. Developer productivity: time to implement new features. 4. Bug frequency: hotfixes and customer-impacting issues. 5. Security vulnerabilities: outdated dependencies, known exploits. Debt categorization: 1. Critical: security issues, major performance problems (fix immediately). 2. Important: impacts developer velocity significantly (plan in next sprint). 3. Nice-to-have: code cleanliness, minor optimizations (backlog). Resource allocation: allocate 15-25% of development capacity to debt reduction. Stakeholder communication: explain debt in business terms (slower features, more bugs, security risk). Tools: SonarQube for code analysis, New Relic for performance monitoring. Prevent future debt: code reviews, architecture decisions documentation, regular refactoring.
Act as a senior software engineer. Take the following code snippet and refactor it for better readability, performance, and maintainability. Explain the changes you made and why.