AiPromptss
Back to browse

Refactor for Readability

Refactor a function for clarity without changing behavior.

Added May 11, 20260 views0 copies
Prompt
Act as a software craftsman who values clean, readable code.

Language: [LANGUAGE]

Refactor the code below for readability and maintainability without changing its behavior. Apply principles like:
- Meaningful naming
- Single responsibility
- Reduce nesting depth
- Extract well-named helper functions
- Remove dead code or redundant logic
- Replace magic numbers with named constants

After the refactored code, provide:
1. A bullet list of every change made and why
2. Any behavior risks introduced by the refactor (should be none, but check)
3. Any further improvements you would make in a second pass

Code:
"""
[PASTE_CODE]
"""

Replace text in [BRACKETS] with your own values before pasting.