Skip to content

Results for “refactor”

6 prompts

This code is too clever and hard to read. Rewrite it for clarity: descriptive names, small functions, comments only where needed, and the same behaviour. Explain what the original was doing. Code: [paste code]

ChatGPT
Coding & Development

Code golf to clean code

Expands clever, cryptic code into readable code.

0

Refactor this callback-based code to use async/await. Keep the behaviour identical, add proper try/catch error handling, and explain any changes in execution order. Code: [paste code]

ChatGPT
Coding & Development

Convert callbacks to async/await

Modernises callback-based code to promises and async/await.

0

Suggest better names in this code. Language and naming conventions: [details] ``` [paste] ``` For each unclear name, give 2–3 alternatives and explain why they're clearer. Then show the code with the best names applied. Don't change behaviour.

ChatGPT
Coding & Development

Better names for variables and functions

Get clearer, more descriptive names for confusing variables, functions and classes.

0

You are a staff engineer experienced with legacy systems. System: [description, age, language] Pain points: [bugs, slow changes, outdated libraries] Constraints: [can't stop shipping features, limited tests] Create a plan: characterisation tests first, the strangler-fig approach, which areas to modernise first (by ris…

Claude
Coding & Development

Modernise legacy code

Plan an incremental modernisation of old code without a risky big-bang rewrite.

0

You are a software architect and teacher. Problem I'm facing: [e.g. many if/else branches for payment types, objects hard to test] Code: ``` [paste] ``` Suggest 1–2 design patterns that fit (and one that doesn't, with why), explain them simply, show my code refactored with the pattern, and discuss trade-offs. Avoid ov…

Claude
Coding & Development

Design patterns applied to your code

Learn which design pattern fits your problem and see it applied to your code.

0

Refactor the code below to make it clean and maintainable, without changing its behaviour. Language: [language] Style guide or conventions: [e.g. PEP 8, Airbnb] Goals: - Clear, descriptive names - Small functions with a single responsibility - Remove duplication and dead code - Simplify nested conditions (early return…

Claude
Coding & Development

Refactor messy code for readability

Clean up hard-to-read code with better names, smaller functions and less duplication, without changing what it does.

0