The method
Use this prompt by providing a code snippet and specifying the desired refactoring goals. Best used in code editors or IDEs. Paste the prompt before your code and specify the target language. Experiment by providing different languages and goals to see how the response changes.
The prompts
                                            Prompt 1
                                            
                                        
                                        Please refactor the following Python code to improve its readability and adhere to PEP 8 style guidelines. Focus on simplifying complex logic, adding comments where necessary, and using descriptive variable names.  ```python
def calculate_value(a, b, c):
x = a * b
y = x + c
return y
```
                                    def calculate_value(a, b, c):
x = a * b
y = x + c
return y
```
                                            Prompt 2
                                            
                                        
                                        Refactor the following JavaScript code to enhance performance by reducing redundant calculations and optimizing loop structures. Also, ensure that the code is well-documented with JSDoc style comments.  ```javascript
function processArray(arr) {
let sum = 0;
for (let i = 0; i < arr.length; i++) {
sum += arr[i];
}
let average = sum / arr.length;
return average;
}
```
                                    function processArray(arr) {
let sum = 0;
for (let i = 0; i < arr.length; i++) {
sum += arr[i];
}
let average = sum / arr.length;
return average;
}
```
                                            Prompt 3
                                            
                                        
                                        Refactor the following Java code to use design patterns where appropriate, such as the Strategy pattern or the Factory pattern, to improve extensibility and maintainability. Document any design choices made during refactoring. ```java
public class OrderProcessor {
public void processOrder(String orderType) {
if (orderType.equals("online")) {
// Process online order
System.out.println("Processing online order");
} else if (orderType.equals("phone")) {
// Process phone order
System.out.println("Processing phone order");
} else {
// Process in-store order
System.out.println("Processing in-store order");
}
}
}
```
                                    public class OrderProcessor {
public void processOrder(String orderType) {
if (orderType.equals("online")) {
// Process online order
System.out.println("Processing online order");
} else if (orderType.equals("phone")) {
// Process phone order
System.out.println("Processing phone order");
} else {
// Process in-store order
System.out.println("Processing in-store order");
}
}
}
```
