ChatGPT Generative AI Prompts
Code Generation
As a [programming language] engineer working on a health booking system, I need a [programming language] code snippet to generate a QR code that users can use to confirm their appointments. Here are the requirements: - [define each requirement in a bullet point] Can you provide a [programming language] code snippet that meets these requirements and follows best practices for error handling and performance?
Code Review
I am a [programming language] developer working on a [describe the project]. Here is a piece of [programming language] code I wrote for [specific task]: [put the code here] Can you review it with a focus on best practices, potential performance improvements, and maintainability, especially considering that this will be part of a large-scale project?
Database Optimisation
As a [programming language] engineer working on [describe the project] using [programming language] and [database system], I am trying to optimize a query that [specific task]. The system will be handling a large number of requests, so performance is critical. Here is the query: [put the code here] This query needs to be optimized to handle high traffic and ensure that we don't encounter performance bottlenecks. Could you suggest ways to improve the performance, such as adding appropriate indexes, query restructuring, or even tweaking the way it is being executed on the .NET side?
Debugging Assistance
As a [programming language] engineer, I’m working on a [describe the project] using [programming language]. I am encountering an issue [describe the issue] while trying to [specific task]. Here is the code snippet: [put the code here] Can you help diagnose the root cause and suggest a fix by considering coding best practices, security, performance, and scalability?
Design Pattern
I am a [programming language] engineer working on [describe the project]. I am implementing the [design pattern] for [describe the function]. The goal is to ensure that the pattern is applied correctly and that the code remains maintainable and easy to extend by the team. Here is the code snippet: [put the code here] Could you provide guidance on how to structure these classes and interfaces effectively to adhere to best practices, ensure scalability, and maintain a clean separation of concerns?
Refactoring
I am a [programming language] engineer working on refactoring the [describe the project] built with [programming language]. The current code for [specific task] feels cluttered and hard to maintain. I want to make it more readable and easier for other team members, especially junior developers, to work with. Here is the code snippet: [put the code here] I am aiming for cleaner, more maintainable code while adhering to best practices like reducing redundancy. Can you suggest how I can refactor this code to achieve that?
Writing Unit Tests
I am a [programming language] engineer working on an [specific task] for a [describe the project] . I need to write comprehensive unit tests to ensure this method functions correctly in all scenarios. Here is the method: [put the code here] I'm using [unit test libraries] for testing and want to cover edge cases. Could you help me design test cases that account for these scenarios, including mocking the database context?