diff --git a/README.prompts.md b/README.prompts.md index 12fc8a2..45b9abb 100644 --- a/README.prompts.md +++ b/README.prompts.md @@ -97,6 +97,7 @@ Ready-to-use prompt templates for specific development scenarios and tasks, defi | [Project Workflow Documentation Generator](prompts/project-workflow-analysis-blueprint-generator.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fproject-workflow-analysis-blueprint-generator.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fproject-workflow-analysis-blueprint-generator.prompt.md) | Comprehensive technology-agnostic prompt generator for documenting end-to-end application workflows. Automatically detects project architecture patterns, technology stacks, and data flow patterns to generate detailed implementation blueprints covering entry points, service layers, data access, error handling, and testing approaches across multiple technologies including .NET, Java/Spring, React, and microservices architectures. | | [README Generator Prompt](prompts/readme-blueprint-generator.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Freadme-blueprint-generator.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Freadme-blueprint-generator.prompt.md) | Intelligent README.md generation prompt that analyzes project documentation structure and creates comprehensive repository documentation. Scans .github/copilot directory files and copilot-instructions.md to extract project information, technology stack, architecture, development workflow, coding standards, and testing approaches while generating well-structured markdown documentation with proper formatting, cross-references, and developer-focused content. | | [Refactoring Java Methods with Extract Method](prompts/java-refactoring-extract-method.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fjava-refactoring-extract-method.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fjava-refactoring-extract-method.prompt.md) | Refactoring using Extract Methods in Java Language | +| [Refactoring Java Methods with Remove Parameter](prompts/java-refactoring-remove-parameter.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fjava-refactoring-remove-parameter.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fjava-refactoring-remove-parameter.prompt.md) | Refactoring using Remove Parameter in Java Language | | [Repo Story Time](prompts/repo-story-time.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Frepo-story-time.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Frepo-story-time.prompt.md) | Generate a comprehensive repository summary and narrative story from commit history | | [Review And Refactor](prompts/review-and-refactor.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Freview-and-refactor.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Freview-and-refactor.prompt.md) | Review and refactor code in your project according to defined instructions | | [Ruby MCP Server Generator](prompts/ruby-mcp-server-generator.prompt.md)
[![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fruby-mcp-server-generator.prompt.md)
[![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://aka.ms/awesome-copilot/install/prompt?url=vscode-insiders%3Achat-prompt%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fprompts%2Fruby-mcp-server-generator.prompt.md) | Generate a complete Model Context Protocol server project in Ruby using the official MCP Ruby SDK gem. | diff --git a/prompts/java-refactoring-remove-parameter.prompt.md b/prompts/java-refactoring-remove-parameter.prompt.md new file mode 100644 index 0000000..7cf6d53 --- /dev/null +++ b/prompts/java-refactoring-remove-parameter.prompt.md @@ -0,0 +1,85 @@ +--- +title: 'Refactoring Java Methods with Remove Parameter' +mode: 'agent' +description: 'Refactoring using Remove Parameter in Java Language' +--- + +# Refactoring Java Methods with Remove Parameter + +## Role + +You are an expert in refactoring Java methods. + +Below are **2 examples** (with titles code before and code after refactoring) that represents **Remove Parameter**. + +## Code Before Refactoring 1: +```java +public Backend selectBackendForGroupCommit(long tableId, ConnectContext context, boolean isCloud) + throws LoadException, DdlException { + if (!Env.getCurrentEnv().isMaster()) { + try { + long backendId = new MasterOpExecutor(context) + .getGroupCommitLoadBeId(tableId, context.getCloudCluster(), isCloud); + return Env.getCurrentSystemInfo().getBackend(backendId); + } catch (Exception e) { + throw new LoadException(e.getMessage()); + } + } else { + return Env.getCurrentSystemInfo() + .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster(), isCloud)); + } +} +``` + +## Code After Refactoring 1: +```java +public Backend selectBackendForGroupCommit(long tableId, ConnectContext context) + throws LoadException, DdlException { + if (!Env.getCurrentEnv().isMaster()) { + try { + long backendId = new MasterOpExecutor(context) + .getGroupCommitLoadBeId(tableId, context.getCloudCluster()); + return Env.getCurrentSystemInfo().getBackend(backendId); + } catch (Exception e) { + throw new LoadException(e.getMessage()); + } + } else { + return Env.getCurrentSystemInfo() + .getBackend(selectBackendForGroupCommitInternal(tableId, context.getCloudCluster())); + } +} +``` + +## Code Before Refactoring 2: +```java +NodeImpl( long id, long firstRel, long firstProp ) +{ + this( id, false ); +} +``` + +## Code After Refactoring 2: +```java +NodeImpl( long id) +{ + this( id, false ); +} +``` + +## Task + +Apply **Remove Parameter** to improve readability, testability, maintainability, reusability, modularity, cohesion, low coupling, and consistency. + +Always return a complete and compilable method (Java 17). + +Perform intermediate steps internally: +- First, analyze each method and identify parameters that are unused or redundant (i.e., values that can be obtained from class fields, constants, or other method calls). +- For each qualifying method, remove the unnecessary parameters from its definition and from all its internal calls. +- Ensure that the method continues to function correctly after parameter removal. +- Output only the refactored code inside a single ```java``` block. +- Do not remove any functionality from the original method. +- Include a one-line comment above each modified method indicating which parameter was removed and why. + +## Code to be Refactored: + +Now, assess all methods with unused parameters and refactor them using **Remove Parameter** \ No newline at end of file