Coding, Development & IT Security Difficulty: Advanced

Best Practices for Refactoring Provided Code Snippet

This prompt instructs an experienced software engineer to analyze the provided code snippet and generate a detailed set of best practices for refactoring it. The output should include specific recommendations that improve code quality, maintainability, and performance. The response must be structured as a professional guideline document suitable for immediate application.

The prompt

73 words1 blank to fill in

Act as an experienced software engineer with expertise in code refactoring. Based on the provided code snippet [CODE SNIPPET], placeholder, analyze the code to identify areas for improvement. Create a comprehensive set of best practices for refactoring that enhance code readability, maintainability, efficiency, and scalability. Include specific recommendations such as design patterns, code structure improvements, optimization techniques, and potential pitfalls to avoid. Present the output as a structured guideline document ready for immediate implementation.

Highlighted text is a blank. Swap it for your own detail before you send the prompt.

What it produces

  • Identify redundant code blocks and suggest consolidation.
  • Recommend applying the Single Responsibility Principle to improve modularity.
  • Suggest replacing nested conditionals with polymorphism or strategy pattern.
  • Highlight opportunities to improve variable naming for clarity.
  • Advise on removing code smells such as long methods or duplicated logic.

How to use this prompt

Four steps, about a minute. Nothing to install and no account needed.

  1. Copy the prompt

    Use the Copy button above. The whole prompt goes to your clipboard exactly as written. Nothing is trimmed.

  2. Fill in the blanks

    Replace [CODE SNIPPET] with your own detail. Everything in square brackets is a blank for you to fill in.

  3. Paste it into your assistant

    Checked against ChatGPT, Claude, Gemini. It is written as plain instructions, so paste it into whichever of them you already use.

  4. Read the result, then push back

    Compare what you get to the example below. If it is close but not right, say what to change: shorter, warmer, more specific, then ask again in the same conversation.

More prompts like this one

Close neighbours in Coding, Development & IT Security, by shared subject and tagging.

Share Best Practices for Refactoring Provided Code Snippet:

Reviews and questions

What other people got out of this prompt, and what they asked about it.

No reviews yet

Be the first to share how this prompt worked for you.