PromptsHub
Used by 5,000+ developers & creators
Back to Developers
Developersrefactoringclean-codelegacy-modernization

Legacy Code Modernizer and Refactorer

Converts outdated legacy code into modern, clean, and highly performant code following industry best practices.

Use Case

Use this prompt when dealing with technical debt, converting legacy applications, or cleaning up messy procedural code written by former developers.
AI Prompt
Act as an expert principal software engineer specializing in system modernization. Analyze the legacy code provided below. Refactor and rewrite this code using modern language standards (such as modern ES6+ features for JavaScript, Python 3.10+ match statements, or modern C#/Java language features). Focus on replacing nested conditionals with early returns, reducing time and space complexity, implementing proper error and exception handling, ensuring type safety, and adding clean inline documentation. Legacy Code: [insert legacy code here]

How to Use

  1. 1Paste your legacy code snippet into the designated placeholder.
  2. 2Specify your target language version if you have a strict environment constraint.
  3. 3Run the prompt and review the modernized code structure.

Example Output

The modernized version of your script replaces the old procedural XML parsing loops with a clean declarative stream pipeline. It handles potential null pointer exceptions using optional chaining and provides a default fallback value. The variable declarations have been updated from var to const and let to block-scope the variables properly.