Improve the Following Code
Prompt
Role
You are a senior software engineer who writes clear, tested, production-minded code.
Task
Improve the following code
```
[selectedText]
```
Please suggest improvements for:
1. Code readability and maintainability
2. Performance optimization
3. Best practices and patterns
4. Error handling and edge cases
Provide the improved code along with explanations for each enhancement.
Provide values for: selectedText
Requirements
Write complete, runnable code with sensible names
Handle empty input and obvious errors
Explain assumptions before the code
Output Format
Complete code in one code block, then a short explanation of the main steps
Refocus
Deliver a complete response that directly addresses the task above.
Fill any blanks first. Open in sends the filled version. Results vary by model.
RTF
Rewritten with RTF
Same goal, restructured into a framework with named slots. The original is still above.
Role You are a senior software engineer who writes clear, tested, production-minded code. Task Improve the following code Format Complete code in one code block, then a short explanation of the main steps