Amazon Q Developer Workshop

Amazon Q Logo

Module 3: Enhancing the Application with Advanced Prompting

In this module, you'll learn how to use advanced prompting techniques with Amazon Q Developer to significantly enhance your Sudoku web application. By crafting more detailed and specific prompts, you can get better results and build a more sophisticated application.

Prerequisites

Step 1: Understanding Advanced Prompting Techniques

Before we start enhancing our application, let's understand some principles of effective prompting with Amazon Q:

  1. Be specific and detailed: Provide context, requirements, and constraints
  2. Break down complex tasks: Ask for one feature at a time
  3. Iterative refinement: Start with a basic implementation, then ask for improvements
  4. Provide examples: When possible, show examples of what you want
  5. Ask for explanations: Request explanations of how the code works

Step 2: Enhancing the UI with Detailed Prompts

  1. Use a detailed prompt to enhance the UI (IDE or CLI):
I want to enhance my Sudoku game UI with the following features:
1. A modern, clean design with a color scheme that reduces eye strain
2. A responsive layout that works well on both desktop and mobile devices
3. Visual feedback for selected cells, valid/invalid entries, and completed rows/columns/boxes
4. A game info panel showing:
   - Current difficulty level
   - Timer
   - Number of mistakes
   - Completion percentage
5. Animations for cell selection and number placement
6. Support for both mouse and keyboard input
  1. Review the result
03_enhance

(Optional) Step 3: Refining and Optimizing with Iterative Prompts

After implementing the enhanced features, you can use Amazon Q to help refine and optimize your code:

For performance optimization:

I've implemented the enhanced Sudoku game, but I'm concerned about performance, especially:

1. The solver algorithm seems slow on difficult puzzles
2. There's a noticeable delay when validating the board after each input
3. The UI becomes less responsive when using the visualization feature

Please suggest optimizations to improve performance while maintaining functionality.

For code quality and organization:

I want to improve the organization and maintainability of my Sudoku game code:

Current issues:
- The code has grown large and is becoming difficult to manage
- There's some duplication in the validation and generation logic
- Event handlers are getting complex with multiple responsibilities

Please suggest how I can:
1. Refactor the code using appropriate design patterns
2. Separate concerns (UI, game logic, state management)
3. Improve code readability and maintainability
4. Add proper error handling

Step 4: Testing Your Enhanced Application

  1. Test all the new features you've implemented
  2. If you encounter any issues, use Amazon Q to help debug:
"I'm having an issue with [specific feature]. Here's the error I'm seeing: [error details].
Here's the relevant code: [paste code]. How can I fix this?"

Next Steps

Congratulations! You've enhanced your Sudoku web application using advanced prompting techniques with Amazon Q Developer. Your application now has more sophisticated features and a better user experience.

In the next module, you'll learn how to deploy your application to AWS using CDK.

Go to Module 4: Deploying with AWS CDK →